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 : boolean
readonlymodule:typing/utils/changebuffer~TypingChangeBuffer#isLocked
Whether the buffer is locked. A locked buffer cannot be reset unless it gets unlocked.
-
limit : number
readonlymodule:typing/utils/changebuffer~TypingChangeBuffer#limit
The maximum number of atomic changes which can be contained in one batch.
-
module:typing/utils/changebuffer~TypingChangeBuffer#model
The model instance.
-
size : number
readonlymodule:typing/utils/changebuffer~TypingChangeBuffer#size
-
module:typing/utils/changebuffer~TypingChangeBuffer#_batch
The current batch instance.
-
_changeCallback : ( evt: EventInfo, batch: Batch ) => void
privatereadonlymodule:typing/utils/changebuffer~TypingChangeBuffer#_changeCallback
The callback to document the change event which later needs to be removed.
-
_isLocked : boolean
privatemodule:typing/utils/changebuffer~TypingChangeBuffer#_isLocked
Whether the buffer is locked. A locked buffer cannot be reset unless it gets unlocked.
-
_selectionChangeCallback : () => void
privatereadonlymodule:typing/utils/changebuffer~TypingChangeBuffer#_selectionChangeCallback
The callback to document selection
change:attribute
andchange:range
events which resets the buffer. -
_size : number
privatemodule:typing/utils/changebuffer~TypingChangeBuffer#_size
Methods
-
constructor( model, limit )
module:typing/utils/changebuffer~TypingChangeBuffer#constructor
Creates a new instance of the change buffer.
Parameters
model : Model
limit : number
The maximum number of atomic changes which can be contained in one batch.
Defaults to
20
-
destroy() → void
module:typing/utils/changebuffer~TypingChangeBuffer#destroy
-
input( changeCount ) → void
module:typing/utils/changebuffer~TypingChangeBuffer#input
-
lock() → void
module:typing/utils/changebuffer~TypingChangeBuffer#lock
-
unlock() → void
module:typing/utils/changebuffer~TypingChangeBuffer#unlock
-
_reset( ignoreLock ) → void
privatemodule:typing/utils/changebuffer~TypingChangeBuffer#_reset
Resets the change buffer.
Parameters
ignoreLock : boolean
Whether internal lock
isLocked
should be ignored.Defaults to
false
Returns
void