From 4fd4ad41c127061c7b5440f72dc3fcd3eae721ee Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 26 Aug 2019 16:10:02 +0200 Subject: [PATCH] improve editor model documentation --- src/editor/model.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/editor/model.js b/src/editor/model.js index 5584627688..689b657f05 100644 --- a/src/editor/model.js +++ b/src/editor/model.js @@ -19,6 +19,13 @@ import {diffAtCaret, diffDeletion} from "./diff"; import DocumentPosition from "./position"; import Range from "./range"; +/** + * @callback ModelCallback + * @param {DocumentPosition?} caretPosition the position where the caret should be position + * @param {string?} inputType the inputType of the DOM input event + * @param {object?} diff an object with `removed` and `added` strings + */ + /** * @callback TransformCallback * @param {DocumentPosition?} caretPosition the position where the caret should be position @@ -50,6 +57,9 @@ export default class EditorModel { this._transformCallback = transformCallback; } + /** Set a callback for rerendering the model after it has been updated. + * @param {ModelCallback} updateCallback + */ setUpdateCallback(updateCallback) { this._updateCallback = updateCallback; } @@ -376,6 +386,11 @@ export default class EditorModel { return new DocumentPosition(index, totalOffset - currentOffset); } + /** + * Starts a range, which can span across multiple parts, to find and replace text. + * @param {DocumentPosition} position where to start the range + * @return {Range} + */ startRange(position) { return new Range(this, position); }