@codemirror/commands
Advanced tools
Comparing version 0.17.1 to 0.17.2
@@ -0,1 +1,9 @@ | ||
## 0.17.2 (2021-01-22) | ||
### New features | ||
The new `insertTab` command inserts a tab when nothing is selected, and defers to `indentMore` otherwise. | ||
The package now exports a `defaultTabBinding` object that provides a recommended binding for tab (if you must bind tab). | ||
## 0.17.1 (2021-01-06) | ||
@@ -2,0 +10,0 @@ |
@@ -70,6 +70,8 @@ import { StateCommand } from '@codemirror/state'; | ||
declare const indentLess: StateCommand; | ||
declare const insertTab: StateCommand; | ||
declare const emacsStyleKeymap: readonly KeyBinding[]; | ||
declare const standardKeymap: readonly KeyBinding[]; | ||
declare const defaultKeymap: readonly KeyBinding[]; | ||
declare const defaultTabBinding: KeyBinding; | ||
export { copyLineDown, copyLineUp, cursorCharBackward, cursorCharForward, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharForward, deleteCodePointBackward, deleteCodePointForward, deleteGroupBackward, deleteGroupForward, deleteLine, deleteToLineEnd, deleteTrailingWhitespace, emacsStyleKeymap, indentLess, indentMore, indentSelection, insertNewline, insertNewlineAndIndent, moveLineDown, moveLineUp, selectAll, selectCharBackward, selectCharForward, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, transposeChars }; | ||
export { copyLineDown, copyLineUp, cursorCharBackward, cursorCharForward, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, defaultTabBinding, deleteCharBackward, deleteCharForward, deleteCodePointBackward, deleteCodePointForward, deleteGroupBackward, deleteGroupForward, deleteLine, deleteToLineEnd, deleteTrailingWhitespace, emacsStyleKeymap, indentLess, indentMore, indentSelection, insertNewline, insertNewlineAndIndent, insertTab, moveLineDown, moveLineUp, selectAll, selectCharBackward, selectCharForward, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, transposeChars }; |
@@ -567,2 +567,11 @@ import { Transaction, EditorSelection, CharCategory } from '@codemirror/state'; | ||
}; | ||
/// Insert a tab character at the cursor or, if something is selected, | ||
/// use [`indentMore`](#commands.indentMore) to indent the entire | ||
/// selection. | ||
const insertTab = ({ state, dispatch }) => { | ||
if (state.selection.ranges.some(r => !r.empty)) | ||
return indentMore({ state, dispatch }); | ||
dispatch(state.update(state.replaceSelection("\t"), { scrollIntoView: true, annotations: Transaction.userEvent.of("input") })); | ||
return true; | ||
}; | ||
/// Array of key bindings containing the Emacs-style bindings that are | ||
@@ -699,3 +708,8 @@ /// available on macOS by default. | ||
].concat(standardKeymap); | ||
/// A binding that binds Tab to [`insertTab`](#commands.insertTab) and | ||
/// Shift-Tab to [`indentSelection`](#commands.indentSelection). | ||
/// Please see the [Tab example](../../examples/tab/) before using | ||
/// this. | ||
const defaultTabBinding = { key: "Tab", run: insertTab, shift: indentSelection }; | ||
export { copyLineDown, copyLineUp, cursorCharBackward, cursorCharForward, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharForward, deleteCodePointBackward, deleteCodePointForward, deleteGroupBackward, deleteGroupForward, deleteLine, deleteToLineEnd, deleteTrailingWhitespace, emacsStyleKeymap, indentLess, indentMore, indentSelection, insertNewline, insertNewlineAndIndent, moveLineDown, moveLineUp, selectAll, selectCharBackward, selectCharForward, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, transposeChars }; | ||
export { copyLineDown, copyLineUp, cursorCharBackward, cursorCharForward, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, defaultTabBinding, deleteCharBackward, deleteCharForward, deleteCodePointBackward, deleteCodePointForward, deleteGroupBackward, deleteGroupForward, deleteLine, deleteToLineEnd, deleteTrailingWhitespace, emacsStyleKeymap, indentLess, indentMore, indentSelection, insertNewline, insertNewlineAndIndent, insertTab, moveLineDown, moveLineUp, selectAll, selectCharBackward, selectCharForward, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, transposeChars }; |
{ | ||
"name": "@codemirror/commands", | ||
"version": "0.17.1", | ||
"version": "0.17.2", | ||
"description": "Collection of editing commands for the CodeMirror code editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
163676
1595