Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 4fd4ad4

Browse files
committed
improve editor model documentation
1 parent f8f0e77 commit 4fd4ad4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/editor/model.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ import {diffAtCaret, diffDeletion} from "./diff";
1919
import DocumentPosition from "./position";
2020
import Range from "./range";
2121

22+
/**
23+
* @callback ModelCallback
24+
* @param {DocumentPosition?} caretPosition the position where the caret should be position
25+
* @param {string?} inputType the inputType of the DOM input event
26+
* @param {object?} diff an object with `removed` and `added` strings
27+
*/
28+
2229
/**
2330
* @callback TransformCallback
2431
* @param {DocumentPosition?} caretPosition the position where the caret should be position
@@ -50,6 +57,9 @@ export default class EditorModel {
5057
this._transformCallback = transformCallback;
5158
}
5259

60+
/** Set a callback for rerendering the model after it has been updated.
61+
* @param {ModelCallback} updateCallback
62+
*/
5363
setUpdateCallback(updateCallback) {
5464
this._updateCallback = updateCallback;
5565
}
@@ -376,6 +386,11 @@ export default class EditorModel {
376386
return new DocumentPosition(index, totalOffset - currentOffset);
377387
}
378388

389+
/**
390+
* Starts a range, which can span across multiple parts, to find and replace text.
391+
* @param {DocumentPosition} position where to start the range
392+
* @return {Range}
393+
*/
379394
startRange(position) {
380395
return new Range(this, position);
381396
}

0 commit comments

Comments
 (0)