You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -48,7 +48,7 @@ Document dispatches these events:
48
48
49
49
__change__ -- When the text of the editor changes (including due to undo/redo).
50
50
51
-
Passes ({'Document'}, {'ChangeList'}), where ChangeList is an array
51
+
Passes (`Document`, `ChangeList`), where ChangeList is an array
52
52
of change record objects. Each change record looks like:
53
53
```js
54
54
{ from: start of change, expressed as {line:<line number>, ch:<character offset>},
@@ -214,8 +214,8 @@ fixed when we migrate to use CodeMirror's native document-linking functionality.
214
214
| Param | Type | Description |
215
215
| --- | --- | --- |
216
216
| text | <code>string</code> | Text to insert or replace the range with |
217
-
| start | <code>Object</code> | Start of range, inclusive (if 'to' specified) or insertion point (if not) |
218
-
| end | <code>Object</code> | End of range, exclusive; optional |
217
+
| start |[<code>TextPosition</code>](#TextPosition)| Start of range, inclusive (if 'to' specified) or insertion point (if not) |
218
+
| end |[<code>TextPosition</code>](#TextPosition)| End of range, exclusive; optional |
219
219
| origin | <code>string</code> | Optional string used to batch consecutive edits for undo. If origin starts with "+", then consecutive edits with the same origin will be batched for undo if they are close enough together in time. If origin starts with "*", then all consecutive edit with the same origin will be batched for undo. Edits with origins starting with other characters will not be batched. (Note that this is a higher level of batching than batchOperation(), which already batches all edits within it for undo. Origin batching works across operations.) |
220
220
221
221
<aname="Document+getRange"></a>
@@ -227,8 +227,8 @@ Returns the characters in the given range. Line endings are normalized to '\n'.
227
227
228
228
| Param | Type | Description |
229
229
| --- | --- | --- |
230
-
| start | <code>Object</code> | Start of range, inclusive |
231
-
| end | <code>Object</code> | End of range, exclusive |
230
+
| start |[<code>TextPosition</code>](#TextPosition)| Start of range, inclusive |
231
+
| end |[<code>TextPosition</code>](#TextPosition)| End of range, exclusive |
232
232
233
233
<aname="Document+getLine"></a>
234
234
@@ -243,9 +243,9 @@ Returns the text of the given line (excluding any line ending characters)
Helper function for edit operations that operate on multiple selections. Takes an "edit list"
299
299
that specifies a list of replaceRanges that should occur, but where all the positions are with
300
300
respect to the document state before all the edits (i.e., you don't have to figure out how to fix
@@ -312,11 +312,11 @@ then this function will adjust them as necessary for the effects of other edits,
312
312
flat list of all the selections, suitable for passing to `setSelections()`.
313
313
314
314
**Kind**: instance method of [<code>Document</code>](#Document)
315
-
**Returns**: <code>Object</code> - The list of passed selections adjusted for the performed edits, if any.
315
+
**Returns**: [<code>Array.<SelectionRange></code>](#SelectionRange) - The list of passed selections adjusted for the performed edits, if any.
316
316
317
317
| Param | Type | Description |
318
318
| --- | --- | --- |
319
-
| edits | <code>Object</code> | Specifies the list of edits to perform in a manner similar to CodeMirror's `replaceRange`. This array will be mutated. `edit` is the edit to perform: `text` will replace the current contents of the range between `start` and `end`. If `end` is unspecified, the text is inserted at `start`. `start` and `end` should be positions relative to the document *ignoring* all other edit descriptions (i.e., as if you were only performing this one edit on the document). If any of the edits overlap, an error will be thrown. If `selection` is specified, it should be a selection associated with this edit. If `isBeforeEdit` is set on the selection, the selection will be fixed up for this edit. If not, it won't be fixed up for this edit, meaning it should be expressed in terms of the document state after this individual edit is performed (ignoring any other edits). Note that if you were planning on just specifying `isBeforeEdit` for every selection, you can accomplish the same thing by simply not passing any selections and letting the editor update the existing selections automatically. Note that `edit` and `selection` can each be either an individual edit/selection, or a group of edits/selections to apply in order. This can be useful if you need to perform multiple edits in a row and then specify a resulting selection that shouldn't be fixed up for any of those edits (but should be fixed up for edits related to other selections). It can also be useful if you have several selections that should ignore the effects of a given edit because you've fixed them up already (this commonly happens with line-oriented edits where multiple cursors on the same line should be ignored, but still tracked). Within an edit group, edit positions must be specified relative to previous edits within that group. Also, the total bounds of edit groups must not overlap (e.g. edits in one group can't surround an edit from another group). |
319
+
| edits | <code>Array.<Object></code> | Specifies the list of edits to perform in a manner similar to CodeMirror's `replaceRange`. This array will be mutated. `edit` is the edit to perform: `text` will replace the current contents of the range between `start` and `end`. If `end` is unspecified, the text is inserted at `start`. `start` and `end` should be positions relative to the document *ignoring* all other edit descriptions (i.e., as if you were only performing this one edit on the document). If any of the edits overlap, an error will be thrown. If `selection` is specified, it should be a selection associated with this edit. If `isBeforeEdit` is set on the selection, the selection will be fixed up for this edit. If not, it won't be fixed up for this edit, meaning it should be expressed in terms of the document state after this individual edit is performed (ignoring any other edits). Note that if you were planning on just specifying `isBeforeEdit` for every selection, you can accomplish the same thing by simply not passing any selections and letting the editor update the existing selections automatically. Note that `edit` and `selection` can each be either an individual edit/selection, or a group of edits/selections to apply in order. This can be useful if you need to perform multiple edits in a row and then specify a resulting selection that shouldn't be fixed up for any of those edits (but should be fixed up for edits related to other selections). It can also be useful if you have several selections that should ignore the effects of a given edit because you've fixed them up already (this commonly happens with line-oriented edits where multiple cursors on the same line should be ignored, but still tracked). Within an edit group, edit positions must be specified relative to previous edits within that group. Also, the total bounds of edit groups must not overlap (e.g. edits in one group can't surround an edit from another group). |
320
320
| origin | <code>string</code> | An optional edit origin that's passed through to each replaceRange(). |
321
321
322
322
<aname="Document+getLanguage"></a>
@@ -347,3 +347,27 @@ Reloads the document from FileSystem
347
347
Normalizes line endings the same way CodeMirror would
348
348
349
349
**Kind**: static method of [<code>Document</code>](#Document)
350
+
<aname="TextPosition"></a>
351
+
352
+
## TextPosition : <code>Object</code>
353
+
**Kind**: global typedef
354
+
**Properties**
355
+
356
+
| Name | Type | Description |
357
+
| --- | --- | --- |
358
+
| line | <code>number</code> | Zero-based line number |
359
+
| ch | <code>number</code> | Zero-based character offset |
360
+
361
+
<aname="SelectionRange"></a>
362
+
363
+
## SelectionRange : <code>Object</code>
364
+
**Kind**: global typedef
365
+
**Properties**
366
+
367
+
| Name | Type | Description |
368
+
| --- | --- | --- |
369
+
| start |[<code>TextPosition</code>](#TextPosition)| Start of the selection |
370
+
| end |[<code>TextPosition</code>](#TextPosition)| End of the selection |
371
+
| primary | <code>boolean</code> | Whether this is the primary selection |
372
+
| reversed | <code>boolean</code> | Whether the selection is reversed |
0 commit comments