update last caret from update callback instead of input event
many editor updates are not caused by an input event, so the last caret wasn't always up to date. Updating the caret from the update callback ensures that every time the editor contents is changed, the last caret is updated.
This commit is contained in:
@@ -120,4 +120,17 @@ export default class DocumentPosition {
|
||||
const atEnd = offset >= lastPart.text.length;
|
||||
return new DocumentOffset(offset, atEnd);
|
||||
}
|
||||
|
||||
isAtEnd(model) {
|
||||
if (model.parts.length === 0) {
|
||||
return true;
|
||||
}
|
||||
const lastPartIdx = model.parts.length - 1;
|
||||
const lastPart = model.parts[lastPartIdx];
|
||||
return this.index === lastPartIdx && this.offset === lastPart.text.length;
|
||||
}
|
||||
|
||||
isAtStart() {
|
||||
return this.index === 0 && this.offset === 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user