@difizen/libro-codemirror 0.1.0 → 0.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.
Files changed (114) hide show
  1. package/es/auto-complete/closebrackets.d.ts +12 -0
  2. package/es/auto-complete/closebrackets.d.ts.map +1 -0
  3. package/es/auto-complete/completion.d.ts +57 -0
  4. package/es/auto-complete/completion.d.ts.map +1 -0
  5. package/es/auto-complete/config.d.ts +22 -0
  6. package/es/auto-complete/config.d.ts.map +1 -0
  7. package/es/auto-complete/filter.d.ts +13 -0
  8. package/es/auto-complete/filter.d.ts.map +1 -0
  9. package/es/auto-complete/filter.js +1 -7
  10. package/es/auto-complete/index.d.ts.map +1 -1
  11. package/es/auto-complete/index.js +5 -9
  12. package/es/auto-complete/snippet.d.ts +14 -0
  13. package/es/auto-complete/snippet.d.ts.map +1 -0
  14. package/es/auto-complete/snippet.js +2 -2
  15. package/es/auto-complete/state.d.ts +63 -0
  16. package/es/auto-complete/state.d.ts.map +1 -0
  17. package/es/auto-complete/state.js +5 -16
  18. package/es/auto-complete/theme.d.ts +6 -0
  19. package/es/auto-complete/theme.d.ts.map +1 -0
  20. package/es/auto-complete/tooltip.d.ts +5 -0
  21. package/es/auto-complete/tooltip.d.ts.map +1 -0
  22. package/es/auto-complete/view.d.ts +43 -0
  23. package/es/auto-complete/view.d.ts.map +1 -0
  24. package/es/auto-complete/view.js +2 -13
  25. package/es/auto-complete/word.d.ts +3 -0
  26. package/es/auto-complete/word.d.ts.map +1 -0
  27. package/es/completion.js +1 -1
  28. package/es/config.d.ts +15 -10
  29. package/es/config.d.ts.map +1 -1
  30. package/es/config.js +15 -6
  31. package/es/editor-contribution.d.ts +8 -0
  32. package/es/editor-contribution.d.ts.map +1 -0
  33. package/es/editor-contribution.js +30 -0
  34. package/es/editor.d.ts +40 -10
  35. package/es/editor.d.ts.map +1 -1
  36. package/es/editor.js +241 -45
  37. package/es/hyperlink.d.ts +15 -0
  38. package/es/hyperlink.d.ts.map +1 -0
  39. package/es/indentation-markers/config.d.ts +17 -0
  40. package/es/indentation-markers/config.d.ts.map +1 -0
  41. package/es/indentation-markers/index.d.ts +3 -0
  42. package/es/indentation-markers/index.d.ts.map +1 -0
  43. package/es/indentation-markers/map.d.ts +77 -0
  44. package/es/indentation-markers/map.d.ts.map +1 -0
  45. package/es/indentation-markers/utils.d.ts +27 -0
  46. package/es/indentation-markers/utils.d.ts.map +1 -0
  47. package/es/index.d.ts +3 -1
  48. package/es/index.d.ts.map +1 -1
  49. package/es/index.js +3 -1
  50. package/es/libro-icon.d.ts +3 -0
  51. package/es/libro-icon.d.ts.map +1 -0
  52. package/es/libro-icon.js +2 -2
  53. package/es/lsp/completion.d.ts +5 -0
  54. package/es/lsp/completion.d.ts.map +1 -0
  55. package/es/lsp/completion.js +245 -0
  56. package/es/lsp/format.d.ts +7 -0
  57. package/es/lsp/format.d.ts.map +1 -0
  58. package/es/lsp/format.js +193 -0
  59. package/es/lsp/index.d.ts +7 -0
  60. package/es/lsp/index.d.ts.map +1 -0
  61. package/es/lsp/index.js +6 -0
  62. package/es/lsp/lint.d.ts +3 -0
  63. package/es/lsp/lint.d.ts.map +1 -0
  64. package/es/lsp/lint.js +114 -0
  65. package/es/lsp/protocol.d.ts +7 -0
  66. package/es/lsp/protocol.d.ts.map +1 -0
  67. package/es/lsp/protocol.js +1 -0
  68. package/es/lsp/tooltip.d.ts +3 -0
  69. package/es/lsp/tooltip.d.ts.map +1 -0
  70. package/es/lsp/tooltip.js +113 -0
  71. package/es/lsp/util.d.ts +15 -0
  72. package/es/lsp/util.d.ts.map +1 -0
  73. package/es/lsp/util.js +58 -0
  74. package/es/mode.d.ts.map +1 -1
  75. package/es/module.d.ts +3 -0
  76. package/es/module.d.ts.map +1 -0
  77. package/es/module.js +4 -0
  78. package/es/monitor.d.ts +32 -0
  79. package/es/monitor.d.ts.map +1 -0
  80. package/es/python-lang.d.ts +3 -0
  81. package/es/python-lang.d.ts.map +1 -0
  82. package/es/theme.d.ts +35 -0
  83. package/es/theme.d.ts.map +1 -0
  84. package/es/theme.js +4 -5
  85. package/es/tooltip.d.ts +1 -1
  86. package/es/tooltip.d.ts.map +1 -1
  87. package/es/tooltip.js +2 -4
  88. package/package.json +7 -5
  89. package/src/auto-complete/filter.ts +5 -7
  90. package/src/auto-complete/index.ts +6 -7
  91. package/src/auto-complete/snippet.ts +8 -2
  92. package/src/auto-complete/state.ts +13 -18
  93. package/src/auto-complete/view.ts +7 -13
  94. package/src/completion.ts +2 -2
  95. package/src/config.ts +40 -28
  96. package/src/editor-contribution.ts +17 -0
  97. package/src/editor.ts +226 -50
  98. package/src/hyperlink.ts +1 -1
  99. package/src/indentation-markers/index.ts +3 -3
  100. package/src/indentation-markers/map.ts +9 -9
  101. package/src/index.ts +4 -1
  102. package/src/libro-icon.tsx +4 -0
  103. package/src/lsp/completion.ts +175 -0
  104. package/src/lsp/format.ts +144 -0
  105. package/src/lsp/index.ts +6 -0
  106. package/src/lsp/lint.ts +125 -0
  107. package/src/lsp/protocol.ts +8 -0
  108. package/src/lsp/tooltip.ts +76 -0
  109. package/src/lsp/util.ts +69 -0
  110. package/src/mode.ts +1 -1
  111. package/src/module.ts +8 -0
  112. package/src/theme.ts +4 -4
  113. package/src/tooltip.ts +2 -4
  114. package/src/libro-icon.ts +0 -4
@@ -0,0 +1,30 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _dec, _class;
3
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
5
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
+ import { CodeEditorContribution } from '@difizen/libro-code-editor';
9
+ import { singleton } from '@difizen/mana-app';
10
+ import { codeMirrorDefaultConfig } from "./editor.js";
11
+ import { codeMirrorEditorFactory } from "./factory.js";
12
+ export var CodeMirrorEditorContribution = (_dec = singleton({
13
+ contrib: [CodeEditorContribution]
14
+ }), _dec(_class = /*#__PURE__*/function () {
15
+ function CodeMirrorEditorContribution() {
16
+ _classCallCheck(this, CodeMirrorEditorContribution);
17
+ this.factory = codeMirrorEditorFactory;
18
+ this.defaultConfig = codeMirrorDefaultConfig;
19
+ }
20
+ _createClass(CodeMirrorEditorContribution, [{
21
+ key: "canHandle",
22
+ value:
23
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
+ function canHandle(mime) {
25
+ // default editor
26
+ return 50;
27
+ }
28
+ }]);
29
+ return CodeMirrorEditorContribution;
30
+ }()) || _class);
package/es/editor.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import type { ChangeSet, Extension, Range, StateEffectType, StateCommand, Text } from '@codemirror/state';
1
+ import type { ChangeSet, Extension, Range, StateCommand, StateEffectType, Text } from '@codemirror/state';
2
2
  import { EditorState, StateField } from '@codemirror/state';
3
- import { Decoration, EditorView } from '@codemirror/view';
4
3
  import type { Command, DecorationSet, ViewUpdate } from '@codemirror/view';
5
- import type { IEditor, IEditorConfig, IEditorSelectionStyle, KeydownHandler, IEditorOptions, IModel, IPosition, IRange, ICoordinate, ITextSelection, IToken } from '@difizen/libro-code-editor';
4
+ import { Decoration, EditorView } from '@codemirror/view';
5
+ import type { ICoordinate, IEditor, IEditorConfig, IEditorOptions, IEditorSelectionStyle, IModel, IPosition, IRange, ITextSelection, IToken, KeydownHandler, SearchMatch } from '@difizen/libro-code-editor';
6
+ import type { LSPProvider } from '@difizen/libro-lsp';
6
7
  import { Disposable, Emitter } from '@difizen/mana-app';
7
8
  import type { CodeMirrorConfig } from './config.js';
8
9
  import { EditorConfiguration } from './config.js';
@@ -14,11 +15,17 @@ import { EditorConfiguration } from './config.js';
14
15
  */
15
16
  export declare const codeMirrorDefaultConfig: Required<CodeMirrorConfig>;
16
17
  export declare class CodeMirrorEditor implements IEditor {
18
+ protected highlightEffect: StateEffectType<{
19
+ matches: SearchMatch[];
20
+ currentIndex: number | undefined;
21
+ }>;
22
+ protected highlightMark: Decoration;
23
+ protected selectedMatchMark: Decoration;
24
+ protected highlightField: StateField<DecorationSet>;
17
25
  /**
18
26
  * Construct a CodeMirror editor.
19
27
  */
20
28
  constructor(options: IOptions);
21
- handleTooltipChange: (val: boolean) => void;
22
29
  /**
23
30
  * Initialize the editor binding.
24
31
  */
@@ -71,7 +78,7 @@ export declare class CodeMirrorEditor implements IEditor {
71
78
  /**
72
79
  * Tests whether the editor is disposed.
73
80
  */
74
- get isDisposed(): boolean;
81
+ get disposed(): boolean;
75
82
  /**
76
83
  * Dispose of the resources held by the widget.
77
84
  */
@@ -150,6 +157,7 @@ export declare class CodeMirrorEditor implements IEditor {
150
157
  line: number;
151
158
  ch: number;
152
159
  }): string;
160
+ getSelectionValue(range?: IRange): string;
153
161
  /**
154
162
  * Add a keydown handler to the editor.
155
163
  *
@@ -213,7 +221,13 @@ export declare class CodeMirrorEditor implements IEditor {
213
221
  *
214
222
  * @param text The text to be inserted.
215
223
  */
216
- replaceSelection(text: string): void;
224
+ replaceSelection(text: string, range: IRange): void;
225
+ replaceSelections(edits: {
226
+ text: string;
227
+ range: IRange;
228
+ }[]): void;
229
+ highlightMatches(matches: SearchMatch[], currentIndex: number | undefined): void;
230
+ handleTooltipChange: (val: boolean) => void;
217
231
  /**
218
232
  * Get a list of tokens for the current editor text content.
219
233
  */
@@ -244,7 +258,15 @@ export declare class CodeMirrorEditor implements IEditor {
244
258
  * Handles a mime type change.
245
259
  */
246
260
  protected _onMimeTypeChanged(): void;
247
- protected _buildMarkDecoration(uuid: string, _selections: ISelectionText[]): Range<Decoration>[];
261
+ /**
262
+ * Handles a selections change.
263
+ */
264
+ protected _onSelectionsChanged(args: ITextSelection[]): void;
265
+ /**
266
+ * Clean selections for the given uuid.
267
+ */
268
+ protected _cleanSelections(uuid: string): void;
269
+ protected _buildMarkDecoration(uuid: string, selections: ISelectionText[]): Range<Decoration>[];
248
270
  /**
249
271
  * Converts the selection style to a text marker options.
250
272
  */
@@ -252,6 +274,10 @@ export declare class CodeMirrorEditor implements IEditor {
252
274
  * Construct a caret element representing the position
253
275
  * of a collaborator's cursor.
254
276
  */
277
+ /**
278
+ * Marks selections.
279
+ */
280
+ protected _markSelections(uuid: string, selections: ITextSelection[]): void;
255
281
  /**
256
282
  * Handles a cursor activity event.
257
283
  */
@@ -319,13 +345,17 @@ export declare class CodeMirrorEditor implements IEditor {
319
345
  * the position is no longer valid.
320
346
  */
321
347
  protected _clearHover(): void;
348
+ /**
349
+ * Check for an out of sync editor.
350
+ */
351
+ protected _checkSync(): void;
322
352
  protected _model: IModel;
323
353
  protected _editor: EditorView;
324
354
  protected _selectionMarkers: Record<string, Range<Decoration>[]>;
325
355
  protected _caretHover: HTMLElement | null;
326
356
  protected _config: IConfig;
327
- protected _hoverTimeout: number | undefined;
328
- protected _hoverId: string | undefined;
357
+ protected _hoverTimeout: number;
358
+ protected _hoverId: string;
329
359
  protected _keydownHandlers: KeydownHandler[];
330
360
  protected _selectionStyle: IEditorSelectionStyle;
331
361
  protected _uuid: string;
@@ -338,7 +368,7 @@ export declare class CodeMirrorEditor implements IEditor {
338
368
  }
339
369
  export type IConfig = CodeMirrorConfig;
340
370
  export interface IOptions extends IEditorOptions {
341
- [x: string]: any;
371
+ lspProvider?: LSPProvider;
342
372
  /**
343
373
  * The configuration options for the editor.
344
374
  */
@@ -1 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,KAAK,EACL,eAAe,EACf,YAAY,EACZ,IAAI,EACL,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,WAAW,EAGX,UAAU,EACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,MAAM,EACN,SAAS,EACT,MAAM,EACN,WAAW,EACX,cAAc,EACd,MAAM,EACP,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAKxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAkClD;;GAEG;AAEH;;GAEG;AAQH,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,gBAAgB,CA8C9D,CAAC;AAEF,qBAAa,gBAAiB,YAAW,OAAO;IAC9C;;OAEG;gBACS,OAAO,EAAE,QAAQ;IA2H7B,mBAAmB,QAAS,OAAO,UAEjC;IAEF;;OAEG;IAUH,IAAI,EAAE,MAAM,IAAI,CAEd;IACF;;OAEG;IACH,QAAQ,CAAC,oBAA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aAAa,CAAC,CAAC;CACjD;AAED,MAAM,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAEvC,MAAM,WAAW,QAAS,SAAQ,cAAc;IAC9C,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3B;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,mBAAmB,EACjC,oBAAoB,EAAE,SAAS,EAAE,GAChC,UAAU,CAiBZ;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,qBAAqB,CAAC;CAC9B;AACD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,cAAc,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;CAClC"}
package/es/editor.js CHANGED
@@ -16,9 +16,9 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
16
16
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
17
17
  import { insertNewlineAndIndent, redo as _redo, undo as _undo } from '@codemirror/commands';
18
18
  import { ensureSyntaxTree } from '@codemirror/language';
19
- import { Prec, EditorState, EditorSelection, StateEffect, StateField } from '@codemirror/state';
19
+ import { EditorSelection, EditorState, Prec, StateEffect, StateField } from '@codemirror/state';
20
20
  import { Decoration, EditorView } from '@codemirror/view';
21
- import { defaultSelectionStyle, defaultConfig } from '@difizen/libro-code-editor';
21
+ import { defaultConfig, defaultSelectionStyle } from '@difizen/libro-code-editor';
22
22
  import { findFirstArrayIndex, removeAllWhereFromArray } from '@difizen/libro-common';
23
23
  import { Disposable, Emitter } from '@difizen/mana-app';
24
24
  import { getOrigin, watch } from '@difizen/mana-app';
@@ -74,7 +74,11 @@ var DOWN_ARROW = 40;
74
74
  export var codeMirrorDefaultConfig = _objectSpread(_objectSpread({}, defaultConfig), {}, {
75
75
  mode: 'null',
76
76
  mimetype: 'text/x-python',
77
- theme: 'jupyter',
77
+ theme: {
78
+ light: 'jupyter',
79
+ dark: 'jupyter',
80
+ hc: 'jupyter'
81
+ },
78
82
  smartIndent: true,
79
83
  electricChars: true,
80
84
  keyMap: 'default',
@@ -92,7 +96,7 @@ export var codeMirrorDefaultConfig = _objectSpread(_objectSpread({}, defaultConf
92
96
  styleSelectedText: true,
93
97
  selectionPointer: false,
94
98
  handlePaste: true,
95
- lineWrap: 'off',
99
+ scrollBarHeight: 8,
96
100
  //
97
101
  highlightActiveLineGutter: false,
98
102
  highlightSpecialChars: true,
@@ -117,51 +121,36 @@ export var codeMirrorDefaultConfig = _objectSpread(_objectSpread({}, defaultConf
117
121
  placeholder: ''
118
122
  });
119
123
  export var CodeMirrorEditor = /*#__PURE__*/function () {
124
+ // highlight
125
+
120
126
  /**
121
127
  * Construct a CodeMirror editor.
122
128
  */
123
129
  function CodeMirrorEditor(options) {
124
130
  var _this = this;
125
131
  _classCallCheck(this, CodeMirrorEditor);
126
- this.handleTooltipChange = function (val) {
127
- _this.modalChangeEmitter.fire(val);
128
- };
129
- /**
130
- * Initialize the editor binding.
131
- */
132
- // protected _initializeEditorBinding(): void {
133
- // const sharedModel = this.model.sharedModel as models.IYText;
134
- // this._yeditorBinding = {
135
- // text: sharedModel.ysource,
136
- // awareness: sharedModel.awareness,
137
- // undoManager: sharedModel.undoManager,
138
- // };
139
- // }
140
- this.save = function () {
141
- //
142
- };
143
132
  /**
144
133
  * A signal emitted when either the top or bottom edge is requested.
145
134
  */
146
135
  this.edgeRequestedEmitter = new Emitter();
147
136
  this.edgeRequested = this.edgeRequestedEmitter.event;
148
137
  this.modalChangeEmitter = new Emitter();
138
+ this.handleTooltipChange = function (val) {
139
+ _this.modalChangeEmitter.fire(val);
140
+ };
149
141
  this._selectionMarkers = {};
150
- this._caretHover = null;
151
- this._hoverTimeout = undefined;
152
- this._hoverId = undefined;
153
142
  this._keydownHandlers = new Array();
154
143
  this._uuid = '';
155
144
  this._isDisposed = false;
156
145
  this._lastChange = null;
157
146
  this._editorConfig = new EditorConfiguration(options);
158
- var host = this.host = options['host'];
147
+ var host = this.host = options.host;
159
148
  host.classList.add(EDITOR_CLASS);
160
149
  host.classList.add('jp-Editor');
161
150
  host.addEventListener('focus', this, true);
162
151
  host.addEventListener('blur', this, true);
163
152
  host.addEventListener('scroll', this, true);
164
- this._uuid = options['uuid'] || v4();
153
+ this._uuid = options.uuid || v4();
165
154
 
166
155
  // State and effects for handling the selection marks
167
156
  this._addMark = StateEffect.define();
@@ -220,13 +209,83 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
220
209
  }
221
210
  });
222
211
 
212
+ // handle highlight
213
+ this.highlightEffect = StateEffect.define({
214
+ map: function map(value, mapping) {
215
+ return {
216
+ matches: value.matches.map(function (v) {
217
+ return {
218
+ text: v.text,
219
+ position: mapping.mapPos(v.position)
220
+ };
221
+ }),
222
+ currentIndex: value.currentIndex
223
+ };
224
+ }
225
+ });
226
+ this.highlightMark = Decoration.mark({
227
+ class: 'cm-searchMatch'
228
+ });
229
+ this.selectedMatchMark = Decoration.mark({
230
+ class: 'cm-searchMatch cm-searchMatch-selected libro-selectedtext'
231
+ });
232
+ this.highlightField = StateField.define({
233
+ create: function create() {
234
+ return Decoration.none;
235
+ },
236
+ update: function update(highlights, transaction) {
237
+ // eslint-disable-next-line no-param-reassign
238
+ highlights = highlights.map(transaction.changes);
239
+ var _iterator3 = _createForOfIteratorHelper(transaction.effects),
240
+ _step3;
241
+ try {
242
+ var _loop2 = function _loop2() {
243
+ var ef = _step3.value;
244
+ if (ef.is(_this.highlightEffect)) {
245
+ var e = ef;
246
+ if (e.value.matches.length) {
247
+ // eslint-disable-next-line no-param-reassign
248
+ highlights = highlights.update({
249
+ add: e.value.matches.map(function (m, index) {
250
+ if (index === e.value.currentIndex) {
251
+ return _this.selectedMatchMark.range(m.position, m.position + m.text.length);
252
+ }
253
+ return _this.highlightMark.range(m.position, m.position + m.text.length);
254
+ }),
255
+ filter: function filter(from, to) {
256
+ return !e.value.matches.some(function (m) {
257
+ return m.position >= from && m.position + m.text.length <= to;
258
+ }) || from === to;
259
+ }
260
+ });
261
+ } else {
262
+ // eslint-disable-next-line no-param-reassign
263
+ highlights = Decoration.none;
264
+ }
265
+ }
266
+ };
267
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
268
+ _loop2();
269
+ }
270
+ } catch (err) {
271
+ _iterator3.e(err);
272
+ } finally {
273
+ _iterator3.f();
274
+ }
275
+ return highlights;
276
+ },
277
+ provide: function provide(f) {
278
+ return EditorView.decorations.from(f);
279
+ }
280
+ });
281
+
223
282
  // Handle selection style.
224
- var style = options['selectionStyle'] || {};
283
+ var style = options.selectionStyle || {};
225
284
  this._selectionStyle = _objectSpread(_objectSpread({}, defaultSelectionStyle), style);
226
- var model = this._model = options['model'];
285
+ var model = this._model = options.model;
227
286
  var config = options.config || {};
228
287
  var fullConfig = this._config = _objectSpread(_objectSpread(_objectSpread({}, codeMirrorDefaultConfig), config), {}, {
229
- mimetype: options['model'].mimeType
288
+ mimetype: options.model.mimeType
230
289
  });
231
290
 
232
291
  // this._initializeEditorBinding();
@@ -272,6 +331,18 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
272
331
 
273
332
  watch(model, 'mimeType', this._onMimeTypeChanged);
274
333
  }
334
+
335
+ /**
336
+ * Initialize the editor binding.
337
+ */
338
+ // protected _initializeEditorBinding(): void {
339
+ // const sharedModel = this.model.sharedModel as models.IYText;
340
+ // this._yeditorBinding = {
341
+ // text: sharedModel.ysource,
342
+ // awareness: sharedModel.awareness,
343
+ // undoManager: sharedModel.undoManager,
344
+ // };
345
+ // }
275
346
  _createClass(CodeMirrorEditor, [{
276
347
  key: "uuid",
277
348
  get:
@@ -364,7 +435,7 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
364
435
  * Tests whether the editor is disposed.
365
436
  */
366
437
  }, {
367
- key: "isDisposed",
438
+ key: "disposed",
368
439
  get: function get() {
369
440
  return this._isDisposed;
370
441
  }
@@ -375,7 +446,7 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
375
446
  }, {
376
447
  key: "dispose",
377
448
  value: function dispose() {
378
- if (this.isDisposed) {
449
+ if (this.disposed) {
379
450
  return;
380
451
  }
381
452
  this._isDisposed = true;
@@ -442,8 +513,7 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
442
513
  key: "getLine",
443
514
  value: function getLine(line) {
444
515
  // TODO: CM6 remove +1 when CM6 first line number has propagated
445
- var _line = line + 1;
446
- return _line <= this.doc.lines ? this.doc.line(_line).text : undefined;
516
+ return line <= this.doc.lines ? this.doc.line(line).text : undefined;
447
517
  }
448
518
 
449
519
  /**
@@ -453,7 +523,7 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
453
523
  key: "getOffsetAt",
454
524
  value: function getOffsetAt(position) {
455
525
  // TODO: CM6 remove +1 when CM6 first line number has propagated
456
- return this.doc.line(position.line + 1).from + position.column;
526
+ return this.doc.line(position.line).from + position.column - 1;
457
527
  }
458
528
 
459
529
  /**
@@ -574,6 +644,13 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
574
644
  var toOffset = this.getOffsetAt(this._toPosition(to));
575
645
  return this.state.sliceDoc(fromOffset, toOffset);
576
646
  }
647
+ }, {
648
+ key: "getSelectionValue",
649
+ value: function getSelectionValue(range) {
650
+ var fromOffset = range ? this.getOffsetAt(range.start) : this.editor.state.selection.main.from;
651
+ var toOffset = range ? this.getOffsetAt(range.end) : this.editor.state.selection.main.to;
652
+ return this.state.sliceDoc(fromOffset, toOffset);
653
+ }
577
654
 
578
655
  /**
579
656
  * Add a keydown handler to the editor.
@@ -752,24 +829,59 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
752
829
  */
753
830
  }, {
754
831
  key: "replaceSelection",
755
- value: function replaceSelection(text) {
756
- this.editor.dispatch(this.state.replaceSelection(text));
832
+ value: function replaceSelection(text, range) {
833
+ this.editor.dispatch({
834
+ changes: {
835
+ from: this.getOffsetAt(range.start),
836
+ to: this.getOffsetAt(range.end),
837
+ insert: text
838
+ }
839
+ });
757
840
  }
758
-
841
+ }, {
842
+ key: "replaceSelections",
843
+ value: function replaceSelections(edits) {
844
+ var _this5 = this;
845
+ // const trans = this.state.replaceSelection(text);
846
+ this.editor.dispatch({
847
+ changes: edits.map(function (item) {
848
+ return {
849
+ from: _this5.getOffsetAt(item.range.start),
850
+ to: _this5.getOffsetAt(item.range.end),
851
+ insert: item.text
852
+ };
853
+ })
854
+ });
855
+ }
856
+ }, {
857
+ key: "highlightMatches",
858
+ value: function highlightMatches(matches, currentIndex) {
859
+ var effects = [this.highlightEffect.of({
860
+ matches: matches,
861
+ currentIndex: currentIndex
862
+ })];
863
+ if (!this.state.field(this.highlightField, false)) {
864
+ effects.push(StateEffect.appendConfig.of([this.highlightField]));
865
+ }
866
+ this.editor.dispatch({
867
+ effects: effects
868
+ });
869
+ }
870
+ }, {
871
+ key: "getTokens",
872
+ value:
759
873
  /**
760
874
  * Get a list of tokens for the current editor text content.
761
875
  */
762
- }, {
763
- key: "getTokens",
764
- value: function getTokens() {
765
- var _this5 = this;
876
+ function getTokens() {
877
+ var _this6 = this;
766
878
  var tokens = [];
767
879
  var tree = ensureSyntaxTree(this.state, this.doc.length);
768
880
  if (tree) {
769
881
  tree.iterate({
770
882
  enter: function enter(node) {
771
883
  tokens.push({
772
- value: _this5.state.sliceDoc(node.from, node.to),
884
+ value: _this6.state.sliceDoc(node.from, node.to),
773
885
  offset: node.from,
774
886
  type: node.name
775
887
  });
@@ -873,21 +985,51 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
873
985
  }, {
874
986
  key: "_onMimeTypeChanged",
875
987
  value: function _onMimeTypeChanged() {
876
- var _this6 = this;
988
+ var _this7 = this;
877
989
  var mime = this._model.mimeType;
878
990
  // TODO: should we provide a hook for when the mode is done being set?
879
991
  void ensure(mime).then(function (spec) {
880
992
  if (spec) {
881
- _this6._editorConfig.reconfigureExtension(_this6._editor, 'language', spec.support);
993
+ _this7._editorConfig.reconfigureExtension(_this7._editor, 'language', spec.support);
882
994
  }
883
995
  return;
884
996
  });
885
997
  }
998
+
999
+ /**
1000
+ * Handles a selections change.
1001
+ */
1002
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1003
+ }, {
1004
+ key: "_onSelectionsChanged",
1005
+ value: function _onSelectionsChanged(args) {
1006
+ // const uuid = args.key;
1007
+ // if (uuid !== this.uuid) {
1008
+ // this._cleanSelections(uuid);
1009
+ // if (args.type !== 'remove' && args.newValue) {
1010
+ // this._markSelections(uuid, args.newValue);
1011
+ // }
1012
+ // }
1013
+ }
1014
+
1015
+ /**
1016
+ * Clean selections for the given uuid.
1017
+ */
1018
+ }, {
1019
+ key: "_cleanSelections",
1020
+ value: function _cleanSelections(uuid) {
1021
+ this.editor.dispatch({
1022
+ effects: this._removeMark.of({
1023
+ uuid: uuid,
1024
+ decorations: this._selectionMarkers[uuid]
1025
+ })
1026
+ });
1027
+ }
886
1028
  }, {
887
1029
  key: "_buildMarkDecoration",
888
1030
  value: function _buildMarkDecoration(uuid,
889
1031
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
890
- _selections) {
1032
+ selections) {
891
1033
  var decorations = [];
892
1034
 
893
1035
  // If we are marking selections corresponding to an active hover,
@@ -963,6 +1105,28 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
963
1105
  // });
964
1106
  // }
965
1107
 
1108
+ /**
1109
+ * Marks selections.
1110
+ */
1111
+ }, {
1112
+ key: "_markSelections",
1113
+ value: function _markSelections(uuid, selections) {
1114
+ var _this8 = this;
1115
+ var sel = selections.map(function (selection) {
1116
+ return {
1117
+ from: _this8.getOffsetAt(selection.start),
1118
+ to: _this8.getOffsetAt(selection.end),
1119
+ style: selection.style
1120
+ };
1121
+ });
1122
+ this.editor.dispatch({
1123
+ effects: this._addMark.of({
1124
+ uuid: uuid,
1125
+ selections: sel
1126
+ })
1127
+ });
1128
+ }
1129
+
966
1130
  /**
967
1131
  * Handles a cursor activity event.
968
1132
  */
@@ -1103,6 +1267,38 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
1103
1267
  this._caretHover = null;
1104
1268
  }
1105
1269
  }
1270
+ /**
1271
+ * Check for an out of sync editor.
1272
+ */
1273
+ }, {
1274
+ key: "_checkSync",
1275
+ value: function _checkSync() {
1276
+ var change = this._lastChange;
1277
+ if (!change) {
1278
+ return;
1279
+ }
1280
+ this._lastChange = null;
1281
+ var doc = this.doc;
1282
+ if (doc.toString() === this._model.value) {
1283
+ return;
1284
+ }
1285
+
1286
+ // void showDialog({
1287
+ // title: this._trans.__('Code Editor out of Sync'),
1288
+ // body: this._trans.__(
1289
+ // 'Please open your browser JavaScript console for bug report instructions',
1290
+ // ),
1291
+ // });
1292
+ console.warn('If you are able and willing to publicly share the text or code in your editor, you can help us debug the "Code Editor out of Sync" message by pasting the following to the public issue at https://github.com/jupyterlab/jupyterlab/issues/2951. Please note that the data below includes the text/code in your editor.');
1293
+ console.warn(JSON.stringify({
1294
+ model: this._model.value,
1295
+ view: doc.toString(),
1296
+ selections: this.getSelections(),
1297
+ cursor: this.getCursorPosition(),
1298
+ lineSep: this.state.facet(EditorState.lineSeparator),
1299
+ change: change
1300
+ }));
1301
+ }
1106
1302
 
1107
1303
  // protected _poll: Poll;
1108
1304
  // protected _yeditorBinding: IYCodeMirrorBinding | null;
@@ -0,0 +1,15 @@
1
+ import type { Extension } from '@codemirror/state';
2
+ import type { DecorationSet, ViewUpdate } from '@codemirror/view';
3
+ import { ViewPlugin } from '@codemirror/view';
4
+ export interface HyperLinkState {
5
+ from: number;
6
+ to: number;
7
+ url: string;
8
+ }
9
+ export declare function hyperLinkExtension(): ViewPlugin<{
10
+ decorations: DecorationSet;
11
+ update(update: ViewUpdate): void;
12
+ }>;
13
+ export declare const hyperLinkStyle: Extension;
14
+ export declare const hyperLink: Extension;
15
+ //# sourceMappingURL=hyperlink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyperlink.d.ts","sourceRoot":"","sources":["../src/hyperlink.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAS,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAsC,MAAM,kBAAkB,CAAC;AAIlF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAqDD,wBAAgB,kBAAkB;;mBAOb,UAAU;GAU9B;AAED,eAAO,MAAM,cAAc,WASzB,CAAC;AAEH,eAAO,MAAM,SAAS,EAAE,SAAkD,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Facet } from '@codemirror/state';
2
+ export interface IndentationMarkerConfiguration {
3
+ /**
4
+ * Determines whether active block marker is styled differently.
5
+ */
6
+ highlightActiveBlock?: boolean;
7
+ /**
8
+ * Determines whether markers in the first column are omitted.
9
+ */
10
+ hideFirstIndent?: boolean;
11
+ /**
12
+ * Determines the type of indentation marker.
13
+ */
14
+ markerType?: 'fullScope' | 'codeOnly';
15
+ }
16
+ export declare const indentationMarkerConfig: Facet<IndentationMarkerConfiguration, Required<IndentationMarkerConfiguration>>;
17
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/indentation-markers/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,UAAU,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;CACvC;AAED,eAAO,MAAM,uBAAuB,iFAWlC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { IndentationMarkerConfiguration } from './config.js';
2
+ export declare function indentationMarkers(config?: IndentationMarkerConfiguration): import("@codemirror/state").Extension[];
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/indentation-markers/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAgLlE,wBAAgB,kBAAkB,CAAC,MAAM,GAAE,8BAAmC,2CAQ7E"}