qword 1.1.0 → 1.1.2
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 +13 -0
- package/client/content.d.ts +1 -1
- package/client/create.d.ts +2 -1
- package/client/create.js +2 -0
- package/client/decorations.d.ts +3 -5
- package/client/dom.d.ts +2 -1
- package/client/editor.d.ts +8 -34
- package/client/editor.js +14 -0
- package/client/editor.spec.js +11 -0
- package/client/events.d.ts +2 -1
- package/client/highlight.d.ts +1 -1
- package/client/history.d.ts +2 -1
- package/client/history.js +4 -6
- package/client/index.d.ts +1 -1
- package/client/index.js +1 -0
- package/client/options.d.ts +3 -2
- package/client/options.js +5 -2
- package/client/position.d.ts +3 -5
- package/client/qword.js +4 -0
- package/client/scroll.d.ts +2 -1
- package/client/types.d.ts +6 -2
- package/dist/qword.js +2 -2
- package/dist/qword.js.map +1 -1
- package/dist-dev/qword.js +3 -3
- package/package.json +8 -8
- package/server/edit.spec.js +1 -0
- package/test/errors.ts +0 -1
- package/test/types.ts +27 -11
package/ChangeLog
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
2026.09.05, v1.1.2
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- d6b691f qword: add indentWithTab and indentUnit support
|
|
5
|
+
|
|
6
|
+
2026.09.05, v1.1.1
|
|
7
|
+
|
|
8
|
+
fix:
|
|
9
|
+
- fc596a1 qword: move codemirror deps to dependencies
|
|
10
|
+
|
|
11
|
+
feature:
|
|
12
|
+
- 1775dca qword: export indentKeymap for indentWithTab support
|
|
13
|
+
|
|
1
14
|
2026.09.05, v1.1.0
|
|
2
15
|
|
|
3
16
|
fix:
|
package/client/content.d.ts
CHANGED
package/client/create.d.ts
CHANGED
|
@@ -29,4 +29,5 @@ export type QwordEditorView = EditorView & {
|
|
|
29
29
|
_historyCompartment: Compartment;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
export function createEditor(element: Element, options?: CreateEditorOptions): QwordEditorView;
|
|
32
|
+
export function createEditor(element: Element, options?: CreateEditorOptions): QwordEditorView;
|
|
33
|
+
|
package/client/create.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
foldGutter,
|
|
11
11
|
codeFolding,
|
|
12
12
|
syntaxHighlighting,
|
|
13
|
+
indentUnit,
|
|
13
14
|
} from '@codemirror/language';
|
|
14
15
|
import {highlightStyle} from './highlight.js';
|
|
15
16
|
import {
|
|
@@ -53,6 +54,7 @@ export function createEditor(element, options = {}) {
|
|
|
53
54
|
keymapCompartment.of(keymapExtension(keyMap)),
|
|
54
55
|
langCompartment.of(languageExtension(mode)),
|
|
55
56
|
syntaxHighlighting(highlightStyle),
|
|
57
|
+
indentUnit.of(' '),
|
|
56
58
|
...lineNumbers
|
|
57
59
|
? [
|
|
58
60
|
lineNumbersExtension(),
|
package/client/decorations.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
type Range,
|
|
3
3
|
StateEffect,
|
|
4
4
|
StateField,
|
|
5
|
-
type Transaction,
|
|
6
5
|
} from '@codemirror/state';
|
|
7
6
|
import {
|
|
8
7
|
Decoration,
|
|
@@ -29,12 +28,11 @@ export type MarkHandle = {
|
|
|
29
28
|
clear: () => void;
|
|
30
29
|
};
|
|
31
30
|
|
|
32
|
-
export function markText(view: EditorView, from: SourcePosition, to: SourcePosition, {
|
|
33
|
-
className,
|
|
34
|
-
}: {
|
|
31
|
+
export function markText(view: EditorView, from: SourcePosition, to: SourcePosition, {className}: {
|
|
35
32
|
className: string;
|
|
36
33
|
}): MarkHandle;
|
|
37
34
|
|
|
38
35
|
export function addLineClass(view: EditorView, line: number, _where: string, className: string): void;
|
|
39
36
|
|
|
40
|
-
export function removeLineClass(view: EditorView, line: number, _where: string, className: string): void;
|
|
37
|
+
export function removeLineClass(view: EditorView, line: number, _where: string, className: string): void;
|
|
38
|
+
|
package/client/dom.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export function getView(container: HTMLElement): EditorView | null;
|
|
|
4
4
|
|
|
5
5
|
export function refresh(view: EditorView): void;
|
|
6
6
|
|
|
7
|
-
export function observeResize(view: EditorView, container: Element): () => void;
|
|
7
|
+
export function observeResize(view: EditorView, container: Element): () => void;
|
|
8
|
+
|
package/client/editor.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from './decorations.js';
|
|
6
|
-
import type {
|
|
7
|
-
OptionKey,
|
|
8
|
-
OptionValue,
|
|
9
|
-
} from './options.js';
|
|
1
|
+
import {
|
|
2
|
+
type QwordEditorView,
|
|
3
|
+
type CreateEditorOptions,
|
|
4
|
+
} from './create.js';
|
|
5
|
+
import type {MarkHandle} from './decorations.js';
|
|
6
|
+
import type {OptionKey, OptionValue} from './options.js';
|
|
10
7
|
import type {
|
|
11
8
|
SourceCode,
|
|
12
9
|
SourcePosition,
|
|
@@ -20,53 +17,30 @@ export type EditorOptions = CreateEditorOptions;
|
|
|
20
17
|
|
|
21
18
|
export default class Editor {
|
|
22
19
|
constructor(element: Element, options?: EditorOptions);
|
|
23
|
-
|
|
24
20
|
getValue(): SourceCode;
|
|
25
|
-
|
|
26
21
|
setValue(value: SourceCode): this;
|
|
27
|
-
|
|
28
22
|
getCursorIndex(): CharOffset;
|
|
29
|
-
|
|
30
23
|
getCursor(): {
|
|
31
24
|
row: number;
|
|
32
25
|
column: number;
|
|
33
26
|
};
|
|
34
|
-
|
|
35
27
|
posFromIndex(index: CharOffset): SourcePosition;
|
|
36
|
-
|
|
37
28
|
focus(): this;
|
|
38
|
-
|
|
39
29
|
moveCursorTo(row: number, column?: number): this;
|
|
40
|
-
|
|
41
30
|
markRange(from: SourcePosition, to: SourcePosition, className: string): MarkHandle;
|
|
42
|
-
|
|
43
31
|
addLineClass(line: number, className: string): this;
|
|
44
|
-
|
|
45
32
|
removeLineClass(line: number, className: string): this;
|
|
46
|
-
|
|
47
33
|
setOption(name: OptionKey, value: OptionValue): this;
|
|
48
|
-
|
|
49
34
|
setMode(mode: EditorMode): this;
|
|
50
|
-
|
|
51
35
|
setTheme(theme: EditorTheme): this;
|
|
52
|
-
|
|
53
36
|
setKeyMap(name: KeyMap): this;
|
|
54
|
-
|
|
55
37
|
setModeForPath(path: string): this;
|
|
56
|
-
|
|
57
38
|
isChanged(): boolean;
|
|
58
|
-
|
|
59
39
|
clearHistory(): this;
|
|
60
|
-
|
|
61
40
|
on(event: string, handler: (...args: unknown[]) => void): this;
|
|
62
|
-
|
|
63
41
|
addListener(event: string, handler: (...args: unknown[]) => void): this;
|
|
64
|
-
|
|
65
42
|
once(event: string, handler: (...args: unknown[]) => void): this;
|
|
66
|
-
|
|
67
43
|
removeListener(event: string, handler: (...args: unknown[]) => void): this;
|
|
68
|
-
|
|
69
44
|
emit(...args: unknown[]): this;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
45
|
+
_view(): QwordEditorView;
|
|
46
|
+
}
|
package/client/editor.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Emitify from 'emitify';
|
|
2
|
+
import {EditorView} from '@codemirror/view';
|
|
2
3
|
import {createEditor} from './create.js';
|
|
3
4
|
import {getValue, setValue} from './content.js';
|
|
4
5
|
import {
|
|
@@ -158,6 +159,19 @@ export default class Editor {
|
|
|
158
159
|
return this;
|
|
159
160
|
}
|
|
160
161
|
|
|
162
|
+
setOptions(options = {}) {
|
|
163
|
+
if (options.fontSize)
|
|
164
|
+
this._view.dispatch({
|
|
165
|
+
effects: this._view._themeCompartment.reconfigure(EditorView.theme({
|
|
166
|
+
'&': {
|
|
167
|
+
fontSize: `${options.fontSize}px`,
|
|
168
|
+
},
|
|
169
|
+
})),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
|
|
161
175
|
get _view() {
|
|
162
176
|
return this.#view;
|
|
163
177
|
}
|
package/client/editor.spec.js
CHANGED
|
@@ -299,6 +299,17 @@ test('Editor: emit calls registered handler', async (t) => {
|
|
|
299
299
|
t.end();
|
|
300
300
|
});
|
|
301
301
|
|
|
302
|
+
test('Editor: setOptions sets font size', (t) => {
|
|
303
|
+
const editor = makeEditor();
|
|
304
|
+
|
|
305
|
+
editor.setOptions({
|
|
306
|
+
fontSize: 20,
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
t.ok(editor);
|
|
310
|
+
t.end();
|
|
311
|
+
});
|
|
312
|
+
|
|
302
313
|
test('Editor: _view getter returns EditorView', (t) => {
|
|
303
314
|
const editor = makeEditor();
|
|
304
315
|
|
package/client/events.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export type EventBinding = [string, EventListener];
|
|
|
4
4
|
|
|
5
5
|
export function on(view: EditorView, event: string, handler: EventListener): EventBinding;
|
|
6
6
|
|
|
7
|
-
export function off(view: EditorView, event: string, handler: EventListener): void;
|
|
7
|
+
export function off(view: EditorView, event: string, handler: EventListener): void;
|
|
8
|
+
|
package/client/highlight.d.ts
CHANGED
package/client/history.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {Compartment} from '@codemirror/state';
|
|
2
2
|
import type {EditorView} from '@codemirror/view';
|
|
3
3
|
|
|
4
|
-
export function clearHistory(view: EditorView, historyCompartment: Compartment, vimEnabled: boolean): void;
|
|
4
|
+
export function clearHistory(view: EditorView, historyCompartment: Compartment, vimEnabled: boolean): void;
|
|
5
|
+
|
package/client/history.js
CHANGED
|
@@ -6,11 +6,9 @@ export function clearHistory(view, historyCompartment, vimEnabled) {
|
|
|
6
6
|
return;
|
|
7
7
|
|
|
8
8
|
view.dispatch({
|
|
9
|
-
effects: historyCompartment.reconfigure(vimEnabled
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
keymap.of(historyKeymap),
|
|
14
|
-
]),
|
|
9
|
+
effects: historyCompartment.reconfigure(vimEnabled ? [] : [
|
|
10
|
+
history(),
|
|
11
|
+
keymap.of(historyKeymap),
|
|
12
|
+
]),
|
|
15
13
|
});
|
|
16
14
|
}
|
package/client/index.d.ts
CHANGED
package/client/index.js
CHANGED
package/client/options.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {type
|
|
1
|
+
import {type Extension} from '@codemirror/state';
|
|
2
2
|
import type {QwordEditorView} from './create.js';
|
|
3
3
|
import type {
|
|
4
4
|
KeyMap,
|
|
@@ -27,4 +27,5 @@ export type OptionValue =
|
|
|
27
27
|
}
|
|
28
28
|
| null;
|
|
29
29
|
|
|
30
|
-
export function setOption(view: QwordEditorView, key: OptionKey, value: OptionValue): void;
|
|
30
|
+
export function setOption(view: QwordEditorView, key: OptionKey, value: OptionValue): void;
|
|
31
|
+
|
package/client/options.js
CHANGED
|
@@ -7,6 +7,7 @@ import {nord} from '@uiw/codemirror-theme-nord';
|
|
|
7
7
|
import {
|
|
8
8
|
defaultKeymap,
|
|
9
9
|
emacsStyleKeymap,
|
|
10
|
+
indentWithTab,
|
|
10
11
|
} from '@codemirror/commands';
|
|
11
12
|
|
|
12
13
|
export function keymapExtension(name) {
|
|
@@ -14,9 +15,9 @@ export function keymapExtension(name) {
|
|
|
14
15
|
return vim();
|
|
15
16
|
|
|
16
17
|
if (name === 'emacs')
|
|
17
|
-
return keymap.of(emacsStyleKeymap);
|
|
18
|
+
return keymap.of([...emacsStyleKeymap, indentWithTab]);
|
|
18
19
|
|
|
19
|
-
return keymap.of(defaultKeymap);
|
|
20
|
+
return keymap.of([...defaultKeymap, indentWithTab]);
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export function themeExtension(name) {
|
|
@@ -26,6 +27,8 @@ export function themeExtension(name) {
|
|
|
26
27
|
return [];
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
export const indentKeymap = keymap.of([indentWithTab]);
|
|
31
|
+
|
|
29
32
|
export function languageExtension(mode) {
|
|
30
33
|
const name = typeof mode === 'object' ? mode?.name : mode;
|
|
31
34
|
|
package/client/position.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type {Text} from '@codemirror/state';
|
|
2
2
|
import type {EditorView} from '@codemirror/view';
|
|
3
|
-
import type {
|
|
4
|
-
CharOffset,
|
|
5
|
-
SourcePosition,
|
|
6
|
-
} from './types.js';
|
|
3
|
+
import type {CharOffset, SourcePosition} from './types.js';
|
|
7
4
|
|
|
8
5
|
export function offsetToPosition(document_: Text, offset: CharOffset): SourcePosition;
|
|
9
6
|
|
|
@@ -18,4 +15,5 @@ export function getCursor(view: EditorView): {
|
|
|
18
15
|
column: number;
|
|
19
16
|
};
|
|
20
17
|
|
|
21
|
-
export function getCursorIndex(view: EditorView): CharOffset;
|
|
18
|
+
export function getCursorIndex(view: EditorView): CharOffset;
|
|
19
|
+
|
package/client/qword.js
CHANGED
|
@@ -92,6 +92,7 @@ export default class Qword extends Editor {
|
|
|
92
92
|
return;
|
|
93
93
|
|
|
94
94
|
const line = this._view.state.doc.line(number);
|
|
95
|
+
|
|
95
96
|
this._view.dispatch({
|
|
96
97
|
selection: {
|
|
97
98
|
anchor: line.from,
|
|
@@ -108,6 +109,7 @@ export default class Qword extends Editor {
|
|
|
108
109
|
|
|
109
110
|
if (direction === 'right') {
|
|
110
111
|
const end = isCollapsed ? to + 1 : to;
|
|
112
|
+
|
|
111
113
|
this._view.dispatch({
|
|
112
114
|
changes: {
|
|
113
115
|
from,
|
|
@@ -133,6 +135,7 @@ export default class Qword extends Editor {
|
|
|
133
135
|
|
|
134
136
|
selectAll() {
|
|
135
137
|
const {doc} = this._view.state;
|
|
138
|
+
|
|
136
139
|
this._view.dispatch({
|
|
137
140
|
selection: {
|
|
138
141
|
anchor: 0,
|
|
@@ -172,6 +175,7 @@ export default class Qword extends Editor {
|
|
|
172
175
|
._story
|
|
173
176
|
.checkHash(path)
|
|
174
177
|
.catch(() => false);
|
|
178
|
+
|
|
175
179
|
return equal ? '' : createPatch(this._savedValue || '', this.getValue());
|
|
176
180
|
}
|
|
177
181
|
}
|
package/client/scroll.d.ts
CHANGED
package/client/types.d.ts
CHANGED
|
@@ -18,7 +18,11 @@ export type KeyMap =
|
|
|
18
18
|
| 'default';
|
|
19
19
|
|
|
20
20
|
// Editor theme name.
|
|
21
|
-
export type EditorTheme =
|
|
21
|
+
export type EditorTheme =
|
|
22
|
+
| 'nord'
|
|
23
|
+
| 'default'
|
|
24
|
+
| 'dark'
|
|
25
|
+
| 'one-dark';
|
|
22
26
|
|
|
23
27
|
// JavaScript/TypeScript source code.
|
|
24
|
-
export type SourceCode = string;
|
|
28
|
+
export type SourceCode = string;
|