TypingChangeBuffer
Change buffer allows to group atomic changes (like characters that have been typed) into batches.
Batches represent single undo steps, hence changes added to one single batch are undone together.
The buffer has a configurable limit of atomic changes that it can accommodate. After the limit was
exceeded (see input), a new batch is created in batch.
To use the change buffer you need to let it know about the number of changes that were added to the batch:
const buffer = new ChangeBuffer( model, LIMIT );
// Later on in your feature:
buffer.batch.insert( pos, insertedCharacters );
buffer.input( insertedCharacters.length );
Properties
-
module:typing/utils/changebuffer~TypingChangeBuffer#batch -
isLocked : booleanreadonlymodule:typing/utils/changebuffer~TypingChangeBuffer#isLockedWhether the buffer is locked. A locked buffer cannot be reset unless it gets unlocked.
-
limit : numberreadonlymodule:typing/utils/changebuffer~TypingChangeBuffer#limitThe maximum number of atomic changes which can be contained in one batch.
-
module:typing/utils/changebuffer~TypingChangeBuffer#modelThe model instance.
-
size : numberreadonlymodule:typing/utils/changebuffer~TypingChangeBuffer#size -
module:typing/utils/changebuffer~TypingChangeBuffer#_batchThe current batch instance.
-
_changeCallback : ( evt: EventInfo, batch: Batch ) => voidprivatereadonlymodule:typing/utils/changebuffer~TypingChangeBuffer#_changeCallbackThe callback to document the change event which later needs to be removed.
-
_isLocked : booleanprivatemodule:typing/utils/changebuffer~TypingChangeBuffer#_isLockedWhether the buffer is locked. A locked buffer cannot be reset unless it gets unlocked.
-
_selectionChangeCallback : () => voidprivatereadonlymodule:typing/utils/changebuffer~TypingChangeBuffer#_selectionChangeCallbackThe callback to document selection
change:attributeandchange:rangeevents which resets the buffer. -
_size : numberprivatemodule:typing/utils/changebuffer~TypingChangeBuffer#_size
Methods
-
constructor( model, limit )module:typing/utils/changebuffer~TypingChangeBuffer#constructorCreates a new instance of the change buffer.
Parameters
model : Modellimit : numberThe maximum number of atomic changes which can be contained in one batch.
Defaults to
20
-
destroy() → voidmodule:typing/utils/changebuffer~TypingChangeBuffer#destroy -
input( changeCount ) → voidmodule:typing/utils/changebuffer~TypingChangeBuffer#input -
lock() → voidmodule:typing/utils/changebuffer~TypingChangeBuffer#lock -
unlock() → voidmodule:typing/utils/changebuffer~TypingChangeBuffer#unlock -
_reset( ignoreLock ) → voidprivatemodule:typing/utils/changebuffer~TypingChangeBuffer#_resetResets the change buffer.
Parameters
ignoreLock : booleanWhether internal lock
isLockedshould be ignored.Defaults to
false
Returns
void