qword 1.1.15 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +11 -0
- package/client/create.js +1 -1
- package/client/editor.d.ts +1 -1
- package/client/editor.js +1 -1
- package/client/index.d.ts +1 -1
- package/client/index.js +1 -1
- package/client/{options.d.ts → options/options.d.ts} +2 -2
- package/client/{options.js → options/options.js} +3 -1
- package/client/options/vim/keep-indent-after-enter-vim.js +55 -0
- package/dist/qword.js +3 -2
- package/dist/qword.js.map +1 -1
- package/dist-dev/qword.js +51 -42
- package/package.json +1 -1
- package/dist/2b22a33a0a80bb926bbc.png +0 -1
- package/dist/8e9019bd86255ac9a618.png +0 -1
- package/dist/codemirror.js +0 -2
- package/dist/codemirror.js.map +0 -1
- package/dist/dword.js +0 -2
- package/dist/dword.js.map +0 -1
- package/dist-dev/2b22a33a0a80bb926bbc.png +0 -1
- package/dist-dev/8e9019bd86255ac9a618.png +0 -1
- package/dist-dev/codemirror.js +0 -104
- package/dist-dev/dword.js +0 -960
package/ChangeLog
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
2026.09.07, v1.1.17
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- 1ab4367 client: options: vim: keep indent after second enter
|
|
5
|
+
- 7bde795 client: options: vim returns array with keepIndentAfterEnterVim
|
|
6
|
+
|
|
7
|
+
2026.09.07, v1.1.16
|
|
8
|
+
|
|
9
|
+
fix:
|
|
10
|
+
- 89f550a double enter in vim mode
|
|
11
|
+
|
|
1
12
|
2026.09.07, v1.1.15
|
|
2
13
|
|
|
3
14
|
fix:
|
package/client/create.js
CHANGED
package/client/editor.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
type CreateEditorOptions,
|
|
4
4
|
} from './create.js';
|
|
5
5
|
import type {MarkHandle} from './decorations.js';
|
|
6
|
-
import type {OptionKey, OptionValue} from './options.js';
|
|
6
|
+
import type {OptionKey, OptionValue} from './options/options.js';
|
|
7
7
|
import type {
|
|
8
8
|
SourceCode,
|
|
9
9
|
SourcePosition,
|
package/client/editor.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
addLineClass,
|
|
13
13
|
removeLineClass,
|
|
14
14
|
} from './decorations.js';
|
|
15
|
-
import {setOption} from './options.js';
|
|
15
|
+
import {setOption} from './options/options.js';
|
|
16
16
|
import {clearHistory} from './history.js';
|
|
17
17
|
import {observeResize} from './dom.js';
|
|
18
18
|
|
package/client/index.d.ts
CHANGED
package/client/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {type Extension} from '@codemirror/state';
|
|
2
|
-
import type {QwordEditorView} from '
|
|
2
|
+
import type {QwordEditorView} from '../create.js';
|
|
3
3
|
import type {
|
|
4
4
|
KeyMap,
|
|
5
5
|
EditorMode,
|
|
6
6
|
EditorTheme,
|
|
7
|
-
} from '
|
|
7
|
+
} from '../types.js';
|
|
8
8
|
|
|
9
9
|
export function keymapExtension(name: KeyMap): Extension;
|
|
10
10
|
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
insertNewlineAndIndent,
|
|
13
13
|
} from '@codemirror/commands';
|
|
14
14
|
|
|
15
|
+
import {keepIndentAfterEnterVim} from './vim/keep-indent-after-enter-vim.js';
|
|
16
|
+
|
|
15
17
|
const enterKeepIndent = {
|
|
16
18
|
key: 'Enter',
|
|
17
19
|
run: insertNewlineAndIndent,
|
|
@@ -19,7 +21,7 @@ const enterKeepIndent = {
|
|
|
19
21
|
|
|
20
22
|
export function keymapExtension(name) {
|
|
21
23
|
if (name === 'vim')
|
|
22
|
-
return vim();
|
|
24
|
+
return [vim(), keepIndentAfterEnterVim];
|
|
23
25
|
|
|
24
26
|
if (name === 'emacs')
|
|
25
27
|
return keymap.of([...emacsStyleKeymap, indentWithTab]);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {EditorState} from '@codemirror/state';
|
|
2
|
+
|
|
3
|
+
export const keepIndentAfterEnterVim = EditorState.transactionFilter.of((tr) => {
|
|
4
|
+
if (!tr.docChanged)
|
|
5
|
+
return tr;
|
|
6
|
+
|
|
7
|
+
const selection = tr.newSelection.main;
|
|
8
|
+
|
|
9
|
+
if (!selection.empty)
|
|
10
|
+
return tr;
|
|
11
|
+
|
|
12
|
+
const pos = selection.head;
|
|
13
|
+
const line = tr.newDoc.lineAt(pos);
|
|
14
|
+
|
|
15
|
+
if (pos !== line.from)
|
|
16
|
+
return tr;
|
|
17
|
+
|
|
18
|
+
if (line.number === 1)
|
|
19
|
+
return tr;
|
|
20
|
+
|
|
21
|
+
const previousLine = tr.newDoc.line(line.number - 1);
|
|
22
|
+
const indent = previousLine.text.match(/^\s*/)?.[0] || '';
|
|
23
|
+
|
|
24
|
+
if (!indent)
|
|
25
|
+
return tr;
|
|
26
|
+
|
|
27
|
+
let insertedNewline = false;
|
|
28
|
+
let alreadyIndented = false;
|
|
29
|
+
|
|
30
|
+
tr.changes.iterChanges((_fromA, _toA, _fromB, _toB, inserted) => {
|
|
31
|
+
const text = inserted.toString();
|
|
32
|
+
|
|
33
|
+
if (text.includes('\n'))
|
|
34
|
+
insertedNewline = true;
|
|
35
|
+
|
|
36
|
+
if (text.endsWith(`\n${indent}`))
|
|
37
|
+
alreadyIndented = true;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (!insertedNewline || alreadyIndented)
|
|
41
|
+
return tr;
|
|
42
|
+
|
|
43
|
+
return [
|
|
44
|
+
tr, {
|
|
45
|
+
changes: {
|
|
46
|
+
from: pos,
|
|
47
|
+
insert: indent,
|
|
48
|
+
},
|
|
49
|
+
selection: {
|
|
50
|
+
anchor: pos + indent.length,
|
|
51
|
+
},
|
|
52
|
+
sequential: true,
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
});
|