@difizen/libro-codemirror 0.0.2-alpha.0 → 0.1.1
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/es/auto-complete/closebrackets.js +1 -1
- package/es/auto-complete/completion.js +5 -5
- package/es/auto-complete/filter.d.ts.map +1 -1
- package/es/auto-complete/filter.js +9 -4
- package/es/auto-complete/index.d.ts.map +1 -1
- package/es/auto-complete/index.js +9 -5
- package/es/auto-complete/snippet.d.ts.map +1 -1
- package/es/auto-complete/snippet.js +6 -8
- package/es/auto-complete/state.d.ts.map +1 -1
- package/es/auto-complete/state.js +29 -22
- package/es/auto-complete/tooltip.js +1 -1
- package/es/auto-complete/view.d.ts +0 -5
- package/es/auto-complete/view.d.ts.map +1 -1
- package/es/auto-complete/view.js +64 -57
- package/es/completion.js +2 -2
- package/es/config.js +5 -5
- package/es/editor.d.ts.map +1 -1
- package/es/editor.js +8 -8
- package/es/factory.js +3 -3
- package/es/hyperlink.js +1 -1
- package/es/indentation-markers/index.js +1 -1
- package/es/indentation-markers/map.js +1 -1
- package/es/mimetype.js +1 -1
- package/es/mode.d.ts.map +1 -1
- package/es/mode.js +2 -7
- package/es/monitor.js +4 -4
- package/es/style/base.css +2 -4
- package/es/style/variables.css +2 -0
- package/es/tooltip.js +1 -1
- package/package.json +6 -6
- package/src/auto-complete/filter.ts +14 -13
- package/src/auto-complete/index.ts +7 -6
- package/src/auto-complete/snippet.ts +3 -11
- package/src/auto-complete/state.ts +26 -27
- package/src/auto-complete/view.ts +10 -8
- package/src/editor.ts +20 -14
- package/src/index.spec.ts +11 -0
- package/src/mode.ts +1 -6
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-parameter-properties */
|
|
2
|
-
/* eslint-disable @typescript-eslint/parameter-properties */
|
|
3
1
|
import type { Transaction } from '@codemirror/state';
|
|
4
2
|
import type {
|
|
5
3
|
EditorView,
|
|
@@ -53,12 +51,16 @@ export function moveCompletionSelection(
|
|
|
53
51
|
);
|
|
54
52
|
}
|
|
55
53
|
const { length } = cState.open.options;
|
|
56
|
-
let selected
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
let selected;
|
|
55
|
+
if (cState.open.selected > -1) {
|
|
56
|
+
selected = cState.open.selected + step * (forward ? 1 : -1);
|
|
57
|
+
} else {
|
|
58
|
+
if (forward) {
|
|
59
|
+
selected = 0;
|
|
60
|
+
} else {
|
|
61
|
+
selected = length - 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
62
64
|
if (selected < 0) {
|
|
63
65
|
selected = by === 'page' ? 0 : length - 1;
|
|
64
66
|
} else if (selected >= length) {
|
package/src/editor.ts
CHANGED
|
@@ -140,7 +140,7 @@ export class CodeMirrorEditor implements IEditor {
|
|
|
140
140
|
*/
|
|
141
141
|
constructor(options: IOptions) {
|
|
142
142
|
this._editorConfig = new EditorConfiguration(options);
|
|
143
|
-
const host = (this.host = options
|
|
143
|
+
const host = (this.host = options['host']);
|
|
144
144
|
|
|
145
145
|
host.classList.add(EDITOR_CLASS);
|
|
146
146
|
host.classList.add('jp-Editor');
|
|
@@ -148,7 +148,7 @@ export class CodeMirrorEditor implements IEditor {
|
|
|
148
148
|
host.addEventListener('blur', this, true);
|
|
149
149
|
host.addEventListener('scroll', this, true);
|
|
150
150
|
|
|
151
|
-
this._uuid = options
|
|
151
|
+
this._uuid = options['uuid'] || v4();
|
|
152
152
|
|
|
153
153
|
// State and effects for handling the selection marks
|
|
154
154
|
this._addMark = StateEffect.define<ICollabSelectionText>();
|
|
@@ -187,19 +187,19 @@ export class CodeMirrorEditor implements IEditor {
|
|
|
187
187
|
});
|
|
188
188
|
|
|
189
189
|
// Handle selection style.
|
|
190
|
-
const style = options
|
|
190
|
+
const style = options['selectionStyle'] || {};
|
|
191
191
|
this._selectionStyle = {
|
|
192
192
|
...defaultSelectionStyle,
|
|
193
193
|
...(style as IEditorSelectionStyle),
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
-
const model = (this._model = options
|
|
196
|
+
const model = (this._model = options['model']);
|
|
197
197
|
|
|
198
198
|
const config = options.config || {};
|
|
199
199
|
const fullConfig = (this._config = {
|
|
200
200
|
...codeMirrorDefaultConfig,
|
|
201
201
|
...config,
|
|
202
|
-
mimetype: options
|
|
202
|
+
mimetype: options['model'].mimeType,
|
|
203
203
|
});
|
|
204
204
|
|
|
205
205
|
// this._initializeEditorBinding();
|
|
@@ -207,13 +207,16 @@ export class CodeMirrorEditor implements IEditor {
|
|
|
207
207
|
// Extension for handling DOM events
|
|
208
208
|
const domEventHandlers = EditorView.domEventHandlers({
|
|
209
209
|
keydown: (event: KeyboardEvent) => {
|
|
210
|
-
const index = findFirstArrayIndex(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
210
|
+
const index = findFirstArrayIndex(
|
|
211
|
+
this._keydownHandlers,
|
|
212
|
+
(handler: KeydownHandler) => {
|
|
213
|
+
if (handler(this, event) === true) {
|
|
214
|
+
event.preventDefault();
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
return false;
|
|
218
|
+
},
|
|
219
|
+
);
|
|
217
220
|
if (index === -1) {
|
|
218
221
|
return this.onKeydown(event);
|
|
219
222
|
}
|
|
@@ -391,7 +394,7 @@ export class CodeMirrorEditor implements IEditor {
|
|
|
391
394
|
// Don't bother setting the option if it is already the same.
|
|
392
395
|
if (this._config[option] !== value) {
|
|
393
396
|
this._config[option] = value;
|
|
394
|
-
this._editorConfig.reconfigureExtension(this._editor, option, value);
|
|
397
|
+
this._editorConfig.reconfigureExtension(this._editor, option as string, value);
|
|
395
398
|
}
|
|
396
399
|
|
|
397
400
|
if (option === 'readOnly') {
|
|
@@ -544,7 +547,10 @@ export class CodeMirrorEditor implements IEditor {
|
|
|
544
547
|
addKeydownHandler(handler: KeydownHandler): Disposable {
|
|
545
548
|
this._keydownHandlers.push(handler);
|
|
546
549
|
return Disposable.create(() => {
|
|
547
|
-
removeAllWhereFromArray(
|
|
550
|
+
removeAllWhereFromArray(
|
|
551
|
+
this._keydownHandlers,
|
|
552
|
+
(val: KeydownHandler) => val === handler,
|
|
553
|
+
);
|
|
548
554
|
});
|
|
549
555
|
}
|
|
550
556
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import assert from 'assert';
|
|
3
|
+
|
|
4
|
+
import { CodeMirrorEditor, codeMirrorEditorFactory } from './index.js';
|
|
5
|
+
|
|
6
|
+
describe('libro-codemirror', () => {
|
|
7
|
+
it('#import', () => {
|
|
8
|
+
assert(CodeMirrorEditor);
|
|
9
|
+
assert(codeMirrorEditorFactory);
|
|
10
|
+
});
|
|
11
|
+
});
|
package/src/mode.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { markdown } from '@codemirror/lang-markdown';
|
|
2
|
-
import type { LanguageSupport } from '@codemirror/language';
|
|
3
2
|
import { LanguageDescription } from '@codemirror/language';
|
|
3
|
+
import type { LanguageSupport } from '@codemirror/language';
|
|
4
4
|
import { defaultMimeType } from '@difizen/libro-code-editor';
|
|
5
|
-
|
|
6
|
-
// This ensures the language spec for python will be loaded when
|
|
7
|
-
// we instantiate a new editor instance, which is required since
|
|
8
|
-
// python is the default language and we don't want to split
|
|
9
|
-
// the editor constructor because of asynchronous loading.
|
|
10
5
|
import { PathExt } from '@difizen/libro-common';
|
|
11
6
|
import { highlightTree } from '@lezer/highlight';
|
|
12
7
|
|