InternalGets a unique symbol for the passed module:engine/model/textproxy~ModelTextProxy instance.
All ModelTextProxy instances that have same parent, same start index and same end index will get the same symbol.
Used internally to correctly consume ModelTextProxy instances.
ModelTextProxy instance to get a symbol for.
Symbol representing all equal instances of ModelTextProxy.
Adds a consumable value to the consumables list and links it with a given model item.
modelConsumable.add( modelElement, 'insert' ); // Add `modelElement` insertion change to consumable values.
modelConsumable.add( modelElement, 'addAttribute:bold' ); // Add `bold` attribute insertion on `modelElement` change.
modelConsumable.add( modelElement, 'removeAttribute:bold' ); // Add `bold` attribute removal on `modelElement` change.
modelConsumable.add( modelSelection, 'selection' ); // Add `modelSelection` to consumable values.
modelConsumable.add( modelRange, 'range' ); // Add `modelRange` to consumable values.
Model item, range or selection that has the consumable.
Consumable type. Will be normalized to a proper form, that is either <word> or <part>:<part>.
Second colon and everything after will be cut. Passing event name is a safe and good practice.
Removes a given consumable value from a given model item.
modelConsumable.consume( modelElement, 'insert' ); // Remove `modelElement` insertion change from consumable values.
modelConsumable.consume( modelElement, 'addAttribute:bold' ); // Remove `bold` attribute insertion on `modelElement` change.
modelConsumable.consume( modelElement, 'removeAttribute:bold' ); // Remove `bold` attribute removal on `modelElement` change.
modelConsumable.consume( modelSelection, 'selection' ); // Remove `modelSelection` from consumable values.
modelConsumable.consume( modelRange, 'range' ); // Remove 'modelRange' from consumable values.
Model item, range or selection from which consumable will be consumed.
Consumable type. Will be normalized to a proper form, that is either <word> or <part>:<part>.
Second colon and everything after will be cut. Passing event name is a safe and good practice.
true if consumable value was available and was consumed, false otherwise.
Reverts consuming of a consumable value.
modelConsumable.revert( modelElement, 'insert' ); // Revert consuming `modelElement` insertion change.
modelConsumable.revert( modelElement, 'addAttribute:bold' ); // Revert consuming `bold` attribute insert from `modelElement`.
modelConsumable.revert( modelElement, 'removeAttribute:bold' ); // Revert consuming `bold` attribute remove from `modelElement`.
modelConsumable.revert( modelSelection, 'selection' ); // Revert consuming `modelSelection`.
modelConsumable.revert( modelRange, 'range' ); // Revert consuming `modelRange`.
Model item, range or selection to be reverted.
Consumable type.
true if consumable has been reversed, false otherwise. null if the consumable has
never been added.
Tests whether there is a consumable value of a given type connected with a given model item.
modelConsumable.test( modelElement, 'insert' ); // Check for `modelElement` insertion change.
modelConsumable.test( modelElement, 'addAttribute:bold' ); // Check for `bold` attribute insertion on `modelElement` change.
modelConsumable.test( modelElement, 'removeAttribute:bold' ); // Check for `bold` attribute removal on `modelElement` change.
modelConsumable.test( modelSelection, 'selection' ); // Check if `modelSelection` is consumable.
modelConsumable.test( modelRange, 'range' ); // Check if `modelRange` is consumable.
Model item, range or selection to be tested.
Consumable type. Will be normalized to a proper form, that is either <word> or <part>:<part>.
Second colon and everything after will be cut. Passing event name is a safe and good practice.
null if such consumable was never added, false if the consumable values was
already consumed or true if it was added and not consumed yet.
Verifies if all events from the specified group were consumed.
The events group to verify.
Manages a list of consumable values for the module:engine/model/item~ModelItem model items.
Consumables are various aspects of the model. A model item can be broken down into separate, single properties that might be taken into consideration when converting that item.
ModelConsumableis used by module:engine/conversion/downcastdispatcher~DowncastDispatcher while analyzing the changed parts of module:engine/model/document~ModelDocument the document. The added / changed / removed model items are broken down into singular properties (the item itself and its attributes). All those parts are saved inModelConsumable. Then, during conversion, when the given part of a model item is converted (i.e. the view element has been inserted into the view, but without attributes), the consumable value is removed fromModelConsumable.For model items,
ModelConsumablestores consumable values of one of following types:insert,addattribute:<attributeKey>,changeattributes:<attributeKey>,removeattributes:<attributeKey>.In most cases, it is enough to let th module:engine/conversion/downcastdispatcher~DowncastDispatcher gather consumable values, so there is no need to use the module:engine/conversion/modelconsumable~ModelConsumable#add add method directly. However, it is important to understand how consumable values can be module:engine/conversion/modelconsumable~ModelConsumable#consume consumed. See module:engine/conversion/downcasthelpers default downcast converters for more information.
Keep in mind that one conversion event may have multiple callbacks (converters) attached to it. Each of those is able to convert one or more parts of the model. However, when one of those callbacks actually converts something, the others should not, because they would duplicate the results. Using
ModelConsumablehelps to avoid this situation, because callbacks should only convert these values that were not yet consumed fromModelConsumable.Consuming multiple values in a single callback: