ChangeBuffer (typing/utils)
@ckeditor/ckeditor5-typing/src/utils/changebuffer
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 );
Filtering
Properties
-
Whether the buffer is locked. A locked buffer cannot be reset unless it gets unlocked.
-
The maximum number of atomic changes which can be contained in one batch.
-
The model instance.
-
The current batch instance.
-
private readonly
_changeCallback : ( evt: EventInfo, batch: Batch ) => voidmodule:typing/utils/changebuffer~ChangeBuffer#_changeCallbackThe callback to document the change event which later needs to be removed.
-
Whether the buffer is locked. A locked buffer cannot be reset unless it gets unlocked.
-
private readonly
_selectionChangeCallback : () => voidmodule:typing/utils/changebuffer~ChangeBuffer#_selectionChangeCallbackThe callback to document selection
change:attributeandchange:rangeevents which resets the buffer.
Methods
-
constructor( model, limit )module:typing/utils/changebuffer~ChangeBuffer#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~ChangeBuffer#destroy -
input( changeCount ) → voidmodule:typing/utils/changebuffer~ChangeBuffer#input -
lock() → voidmodule:typing/utils/changebuffer~ChangeBuffer#lock -
unlock() → voidmodule:typing/utils/changebuffer~ChangeBuffer#unlock -
Resets the change buffer.
Parameters
ignoreLock : booleanWhether internal lock
isLockedshould be ignored.Defaults to
false
Returns
void
Every day, we work hard to keep our documentation complete. Have you spotted outdated information? Is something missing? Please report it via our issue tracker.
With the release of version 42.0.0, we have rewritten much of our documentation to reflect the new import paths and features. We appreciate your feedback to help us ensure its accuracy and completeness.