Skip to content

Commit 4b8b258

Browse files
committed
Indent more keyboard shortcut
1 parent ea8c611 commit 4b8b258

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"@codemirror/state": "^6.4.1",
3333
"@codemirror/view": "^6.34.1",
3434
"@parcel/transformer-typescript-tsc": "^2.12.0",
35-
"@types/node": "^22.7.5",
35+
"@types/node": "^22.7.6",
3636
"@types/react": "^18.3.11",
3737
"@types/react-dom": "^18.3.1",
3838
"@uiw/codemirror-theme-github": "^4.23.5",

src/components/editor.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { defaultKeymap, history, historyKeymap } from '@codemirror/commands';
1+
import {
2+
defaultKeymap,
3+
history,
4+
historyKeymap,
5+
indentMore,
6+
} from '@codemirror/commands';
27
import { markdown } from '@codemirror/lang-markdown';
38
import {
49
defaultHighlightStyle,
@@ -34,6 +39,14 @@ const Editor = auto((props: { store: Store }) => {
3439
}
3540
},
3641
);
42+
43+
// Define the custom key binding
44+
const customKeymap = keymap.of([
45+
{
46+
key: 'Tab',
47+
run: indentMore,
48+
},
49+
]);
3750
const cm = new EditorView({
3851
extensions: [
3952
store.editorTheme.of(githubLight),
@@ -52,6 +65,7 @@ const Editor = auto((props: { store: Store }) => {
5265
keymap.of([...defaultKeymap, ...historyKeymap]),
5366
markdown(),
5467
syntaxHighlighting(defaultHighlightStyle),
68+
customKeymap,
5569
contentChangeListener,
5670
],
5771
parent: editorDiv.current!,

yarn.lock

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,10 +1612,10 @@
16121612
resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
16131613
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==
16141614

1615-
"@types/node@^22.7.5":
1616-
version "22.7.5"
1617-
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.5.tgz#cfde981727a7ab3611a481510b473ae54442b92b"
1618-
integrity sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ==
1615+
"@types/node@^22.7.6":
1616+
version "22.7.6"
1617+
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.6.tgz#3ec3e2b071e136cd11093c19128405e1d1f92f33"
1618+
integrity sha512-/d7Rnj0/ExXDMcioS78/kf1lMzYk4BZV8MZGTBKzTGZ6/406ukkbYlIsZmMPhcR5KlkunDHQLrtAVmSq7r+mSw==
16191619
dependencies:
16201620
undici-types "~6.19.2"
16211621

@@ -4010,11 +4010,16 @@ prop-types@^15.8.1:
40104010
object-assign "^4.1.1"
40114011
react-is "^16.13.1"
40124012

4013-
punycode@^2.1.0, punycode@^2.3.1:
4013+
punycode@^2.1.0:
40144014
version "2.3.1"
40154015
resolved "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5"
40164016
integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==
40174017

4018+
punycode@^2.3.1:
4019+
version "2.3.1"
4020+
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5"
4021+
integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==
4022+
40184023
queue-microtask@^1.2.2:
40194024
version "1.2.3"
40204025
resolved "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"

0 commit comments

Comments
 (0)