ModelDocumentSelection
ModelDocumentSelection is a special selection which is used as the document's selection. There can be only one instance of ModelDocumentSelection per document.
Document selection can only be changed by using the ModelWriter instance inside the change() block, as it provides a secure way to modify model.
ModelDocumentSelection is automatically updated upon changes in the document to always contain valid ranges. Its attributes are inherited from the text unless set explicitly.
Differences between ModelSelection and ModelDocumentSelection are:
- there is always a range in
ModelDocumentSelection- even if no ranges were added there is a "default range" present in the selection, - ranges added to this selection updates automatically when the document changes,
- attributes of
ModelDocumentSelectionare updated automatically according to selection ranges.
Since ModelDocumentSelection uses live ranges and is updated when document changes, it cannot be set on nodes that are inside document fragment. If you need to represent a selection in document fragment, use Selection class instead.
Properties
anchor : null | ModelPositionreadonlymodule:engine/model/documentselection~ModelDocumentSelection#anchorSelection anchor. Anchor may be described as a position where the most recent part of the selection starts. Together with
focusthey define the direction of selection, which is important when expanding/shrinking selection. Anchor is always start or end position of the most recently added range.Is set to
nullif there are no ranges in selection.focus : null | ModelPositionreadonlymodule:engine/model/documentselection~ModelDocumentSelection#focusSelection focus. Focus is a position where the selection ends.
Is set to
nullif there are no ranges in selection.hasOwnRange : booleanreadonlymodule:engine/model/documentselection~ModelDocumentSelection#hasOwnRangeDescribes whether
Documentselectionhas own range(s) set, or if it is defaulted to document's default range.isBackward : booleanreadonlymodule:engine/model/documentselection~ModelDocumentSelection#isBackwardisCollapsed : booleanreadonlymodule:engine/model/documentselection~ModelDocumentSelection#isCollapsedDescribes whether the selection is collapsed. Selection is collapsed when there is exactly one range which is collapsed.
isGravityOverridden : booleanreadonlymodule:engine/model/documentselection~ModelDocumentSelection#isGravityOverriddenDescribes whether the gravity is overridden (using
overrideSelectionGravity) or not.Note that the gravity remains overridden as long as will not be restored the same number of times as it was overridden.
markers : Collection<Marker>readonlymodule:engine/model/documentselection~ModelDocumentSelection#markersA collection of selection markers. Marker is a selection marker when selection range is inside the marker range.
Note: Only markers from observed markers groups are collected.
rangeCount : numberreadonlymodule:engine/model/documentselection~ModelDocumentSelection#rangeCountNumber of ranges in selection.
_ranges : Array<ModelRange>internalreadonlymodule:engine/model/documentselection~ModelDocumentSelection#_rangesUsed for the compatibility with the
isEqualmethod._selection : LiveSelectionprivatemodule:engine/model/documentselection~ModelDocumentSelection#_selectionSelection used internally by that class (
ModelDocumentSelectionis a proxy to that selection).
Methods
constructor( doc )module:engine/model/documentselection~ModelDocumentSelection#constructorCreates an empty live selection for given
ModelDocument.Parameters
doc : ModelDocumentDocument which owns this selection.
containsEntireContent( element ) → booleanmodule:engine/model/documentselection~ModelDocumentSelection#containsEntireContentChecks whether the selection contains the entire content of the given element. This means that selection must start at a position touching the element's start and ends at position touching the element's end.
By default, this method will check whether the entire content of the selection's current root is selected. Useful to check if e.g. the user has just pressed Ctrl + A.
Parameters
element : ModelElement
Returns
boolean
delegate( events ) → EmitterMixinDelegateChaininheritedmodule:engine/model/documentselection~ModelDocumentSelection#delegateDelegates selected events to another
Emitter. For instance:emitterA.delegate( 'eventX' ).to( emitterB ); emitterA.delegate( 'eventX', 'eventY' ).to( emitterC );Copy codethen
eventXis delegated (fired by)emitterBandemitterCalong withdata:emitterA.fire( 'eventX', data );Copy codeand
eventYis delegated (fired by)emitterCalong withdata:emitterA.fire( 'eventY', data );Copy codeParameters
events : Array<string>Event names that will be delegated to another emitter.
Returns
destroy() → voidmodule:engine/model/documentselection~ModelDocumentSelection#destroyfire( eventOrInfo, args ) → GetEventInfo<TEvent>[ 'return' ]inheritedmodule:engine/model/documentselection~ModelDocumentSelection#fireFires an event, executing all callbacks registered for it.
The first parameter passed to callbacks is an
EventInfoobject, followed by the optionalargsprovided in thefire()method call.Type parameters
Parameters
eventOrInfo : GetNameOrEventInfo<TEvent>The name of the event or
EventInfoobject if event is delegated.args : TEvent[ 'args' ]Additional arguments to be passed to the callbacks.
Returns
GetEventInfo<TEvent>[ 'return' ]By default the method returns
undefined. However, the return value can be changed by listeners through modification of theevt.return's property (the event info is the first param of every callback).
getAttribute( key ) → unknownmodule:engine/model/documentselection~ModelDocumentSelection#getAttributeGets an attribute value for given key or
undefinedif that attribute is not set on the selection.Parameters
key : stringKey of attribute to look for.
Returns
unknownAttribute value or
undefined.
getAttributeKeys() → IterableIterator<string>module:engine/model/documentselection~ModelDocumentSelection#getAttributeKeysReturns iterable that iterates over this selection's attribute keys.
Returns
IterableIterator<string>
getAttributes() → IterableIterator<tuple>module:engine/model/documentselection~ModelDocumentSelection#getAttributesReturns iterable that iterates over this selection's attributes.
Attributes are returned as arrays containing two items. First one is attribute key and second is attribute value. This format is accepted by native
Mapobject and also can be passed inNodeconstructor.Returns
IterableIterator<tuple>
getFirstPosition() → null | ModelPositionmodule:engine/model/documentselection~ModelDocumentSelection#getFirstPositionReturns the first position in the selection. First position is the position that is before any other position in the selection.
Returns
nullif there are no ranges in selection.Returns
null | ModelPosition
getFirstRange() → null | ModelRangemodule:engine/model/documentselection~ModelDocumentSelection#getFirstRangeReturns a copy of the first range in the selection. First range is the one which start position is before start position of all other ranges (not to confuse with the first range added to the selection).
Returns
nullif there are no ranges in selection.Returns
null | ModelRange
getLastPosition() → null | ModelPositionmodule:engine/model/documentselection~ModelDocumentSelection#getLastPositionReturns the last position in the selection. Last position is the position that is after any other position in the selection.
Returns
nullif there are no ranges in selection.Returns
null | ModelPosition
getLastRange() → null | ModelRangemodule:engine/model/documentselection~ModelDocumentSelection#getLastRangeReturns a copy of the last range in the selection. Last range is the one which end position is after end position of all other ranges (not to confuse with the range most recently added to the selection).
Returns
nullif there are no ranges in selection.Returns
null | ModelRange
getRanges() → IterableIterator<ModelRange>module:engine/model/documentselection~ModelDocumentSelection#getRangesReturns an iterable that iterates over copies of selection ranges.
Returns
IterableIterator<ModelRange>
getSelectedBlocks() → IterableIterator<ModelElement>module:engine/model/documentselection~ModelDocumentSelection#getSelectedBlocksGets elements of type "block" touched by the selection.
This method's result can be used for example to apply block styling to all blocks covered by this selection.
Note:
getSelectedBlocks()returns blocks that are nested in other non-block elements but will not return blocks nested in other blocks.In this case the function will return exactly all 3 paragraphs (note:
<blockQuote>is not a block itself):<paragraph>[a</paragraph> <blockQuote> <paragraph>b</paragraph> </blockQuote> <paragraph>c]d</paragraph>Copy codeIn this case the paragraph will also be returned, despite the collapsed selection:
<paragraph>[]a</paragraph>Copy codeIn such a scenario, however, only blocks A, B & E will be returned as blocks C & D are nested in block B:
[<blockA></blockA> <blockB> <blockC></blockC> <blockD></blockD> </blockB> <blockE></blockE>]Copy codeIf the selection is inside a block all the inner blocks (A & B) are returned:
<block> <blockA>[a</blockA> <blockB>b]</blockB> </block>Copy codeSpecial case: If a selection ends at the beginning of a block, that block is not returned as from user perspective this block wasn't selected. See #984 for more details.
<paragraph>[a</paragraph> <paragraph>b</paragraph> <paragraph>]c</paragraph> // this block will not be returnedCopy codeReturns
IterableIterator<ModelElement>
getSelectedElement() → null | ModelElementmodule:engine/model/documentselection~ModelDocumentSelection#getSelectedElementReturns the selected element. Element is considered as selected if there is only one range in the selection, and that range contains exactly one element. Returns
nullif there is no selected element.Returns
null | ModelElement
hasAttribute( key ) → booleanmodule:engine/model/documentselection~ModelDocumentSelection#hasAttributeChecks if the selection has an attribute for given key.
Parameters
key : stringKey of attribute to check.
Returns
booleantrueif attribute with given key is set on selection,falseotherwise.
is( type ) → this is ModelElement | ModelRootElementinheritedmodule:engine/model/documentselection~ModelDocumentSelection#is:ELEMENTChecks whether the object is of type
ModelElementor its subclass.element.is( 'element' ); // -> true element.is( 'node' ); // -> true element.is( 'model:element' ); // -> true element.is( 'model:node' ); // -> true element.is( 'view:element' ); // -> false element.is( 'documentSelection' ); // -> falseCopy codeAssuming that the object being checked is an element, you can also check its name:
element.is( 'element', 'imageBlock' ); // -> true if this is an <imageBlock> element text.is( 'element', 'imageBlock' ); -> falseCopy codeParameters
type : 'element' | 'model:element'
Returns
this is ModelElement | ModelRootElement
module:engine/model/documentselection~ModelDocumentSelection#is:TEXTChecks whether the object is of type
ModelText.text.is( '$text' ); // -> true text.is( 'node' ); // -> true text.is( 'model:$text' ); // -> true text.is( 'model:node' ); // -> true text.is( 'view:$text' ); // -> false text.is( 'documentSelection' ); // -> falseCopy codeNote: Until version 20.0.0 this method wasn't accepting
'$text'type. The legacy'text'type is still accepted for backward compatibility.Parameters
type : '$text' | 'model:$text'
Returns
this is ModelText
is( type ) → this is ModelRootElementinheritedmodule:engine/model/documentselection~ModelDocumentSelection#is:ROOT_ELEMENTChecks whether the object is of type
ModelRootElement.rootElement.is( 'rootElement' ); // -> true rootElement.is( 'element' ); // -> true rootElement.is( 'node' ); // -> true rootElement.is( 'model:rootElement' ); // -> true rootElement.is( 'model:element' ); // -> true rootElement.is( 'model:node' ); // -> true rootElement.is( 'view:element' ); // -> false rootElement.is( 'documentFragment' ); // -> falseCopy codeAssuming that the object being checked is an element, you can also check its name:
rootElement.is( 'rootElement', '$root' ); // -> same as aboveCopy codeParameters
type : 'rootElement' | 'model:rootElement'
Returns
this is ModelRootElement
is( type ) → this is ModelLiveRangeinheritedmodule:engine/model/documentselection~ModelDocumentSelection#is:LIVE_RANGEChecks whether the object is of type
ModelLiveRange.liveRange.is( 'range' ); // -> true liveRange.is( 'model:range' ); // -> true liveRange.is( 'liveRange' ); // -> true liveRange.is( 'model:liveRange' ); // -> true liveRange.is( 'view:range' ); // -> false liveRange.is( 'documentSelection' ); // -> falseCopy codeParameters
type : 'liveRange' | 'model:liveRange'
Returns
this is ModelLiveRange
is( type ) → this is ModelRange | ModelLiveRangeinheritedmodule:engine/model/documentselection~ModelDocumentSelection#is:RANGEChecks whether the object is of type
ModelRangeor its subclass.range.is( 'range' ); // -> true range.is( 'model:range' ); // -> true range.is( 'view:range' ); // -> false range.is( 'documentSelection' ); // -> falseCopy codeParameters
type : 'range' | 'model:range'
Returns
this is ModelRange | ModelLiveRange
is( type ) → this is ModelLivePositioninheritedmodule:engine/model/documentselection~ModelDocumentSelection#is:LIVE_POSITIONChecks whether the object is of type
ModelLivePosition.livePosition.is( 'position' ); // -> true livePosition.is( 'model:position' ); // -> true livePosition.is( 'liveposition' ); // -> true livePosition.is( 'model:livePosition' ); // -> true livePosition.is( 'view:position' ); // -> false livePosition.is( 'documentSelection' ); // -> falseCopy codeParameters
type : 'livePosition' | 'model:livePosition'
Returns
this is ModelLivePosition
is( type ) → this is ModelPosition | ModelLivePositioninheritedmodule:engine/model/documentselection~ModelDocumentSelection#is:POSITIONChecks whether the object is of type
ModelPositionor its subclass.position.is( 'position' ); // -> true position.is( 'model:position' ); // -> true position.is( 'view:position' ); // -> false position.is( 'documentSelection' ); // -> falseCopy codeParameters
type : 'position' | 'model:position'
Returns
this is ModelPosition | ModelLivePosition
is( type ) → this is ModelSelection | ModelDocumentSelectioninheritedmodule:engine/model/documentselection~ModelDocumentSelection#is:SELECTIONChecks whether the object is of type
ModelSelectionorModelDocumentSelection.selection.is( 'selection' ); // -> true selection.is( 'model:selection' ); // -> true selection.is( 'view:selection' ); // -> false selection.is( 'range' ); // -> falseCopy codeParameters
type : 'selection' | 'model:selection'
Returns
this is ModelSelection | ModelDocumentSelection
is( type, name ) → booleaninheritedmodule:engine/model/documentselection~ModelDocumentSelection#is:ELEMENT_NAMEChecks whether the object is of type
ModelElementor its subclass and has the specifiedname.element.is( 'element', 'imageBlock' ); // -> true if this is an <imageBlock> element text.is( 'element', 'imageBlock' ); -> falseCopy codeType parameters
N : extends string
Parameters
type : 'element' | 'model:element'name : N
Returns
boolean
is( type, name ) → booleaninheritedmodule:engine/model/documentselection~ModelDocumentSelection#is:ROOT_ELEMENT_NAMEChecks whether the object is of type
ModelRootElementand has the specifiedname.rootElement.is( 'rootElement', '$root' );Copy codeType parameters
N : extends string
Parameters
type : 'rootElement' | 'model:rootElement'name : N
Returns
boolean
is( type ) → this is ModelTextProxyinheritedmodule:engine/model/documentselection~ModelDocumentSelection#is:TEXT_PROXYChecks whether the object is of type
ModelTextProxy.textProxy.is( '$textProxy' ); // -> true textProxy.is( 'model:$textProxy' ); // -> true textProxy.is( 'view:$textProxy' ); // -> false textProxy.is( 'range' ); // -> falseCopy codeNote: Until version 20.0.0 this method wasn't accepting
'$textProxy'type. The legacy'textProxt'type is still accepted for backward compatibility.Parameters
type : '$textProxy' | 'model:$textProxy'
Returns
this is ModelTextProxy
module:engine/model/documentselection~ModelDocumentSelection#is:MARKERis( type ) → this is ModelDocumentSelectioninheritedmodule:engine/model/documentselection~ModelDocumentSelection#is:DOCUMENT_SELECTIONChecks whether the object is of type
ModelDocumentSelection.selection.is( 'selection' ); // -> true selection.is( 'documentSelection' ); // -> true selection.is( 'model:selection' ); // -> true selection.is( 'model:documentSelection' ); // -> true selection.is( 'view:selection' ); // -> false selection.is( 'element' ); // -> false selection.is( 'node' ); // -> falseCopy codeParameters
type : 'documentSelection' | 'model:documentSelection'
Returns
this is ModelDocumentSelection
is( type ) → this is ModelDocumentFragmentinheritedmodule:engine/model/documentselection~ModelDocumentSelection#is:DOCUMENT_FRAGMENTChecks whether the object is of type
ModelDocumentFragment.docFrag.is( 'documentFragment' ); // -> true docFrag.is( 'model:documentFragment' ); // -> true docFrag.is( 'view:documentFragment' ); // -> false docFrag.is( 'element' ); // -> false docFrag.is( 'node' ); // -> falseCopy codeParameters
type : 'documentFragment' | 'model:documentFragment'
Returns
this is ModelDocumentFragment
is( type ) → this is ModelNode | ModelText | ModelElement | ModelRootElementinheritedmodule:engine/model/documentselection~ModelDocumentSelection#is:NODEChecks whether the object is of type
ModelNodeor its subclass.This method is useful when processing model objects that are of unknown type. For example, a function may return a
ModelDocumentFragmentor aModelNodethat can be either a text node or an element. This method can be used to check what kind of object is returned.someObject.is( 'element' ); // -> true if this is an element someObject.is( 'node' ); // -> true if this is a node (a text node or an element) someObject.is( 'documentFragment' ); // -> true if this is a document fragmentCopy codeSince this method is also available on a range of view objects, you can prefix the type of the object with
model:orview:to check, for example, if this is the model's or view's element:modelElement.is( 'model:element' ); // -> true modelElement.is( 'view:element' ); // -> falseCopy codeBy using this method it is also possible to check a name of an element:
imageElement.is( 'element', 'imageBlock' ); // -> true imageElement.is( 'element', 'imageBlock' ); // -> same as above imageElement.is( 'model:element', 'imageBlock' ); // -> same as above, but more preciseCopy codeParameters
type : 'node' | 'model:node'
Returns
this is ModelNode | ModelText | ModelElement | ModelRootElement
listenTo( emitter, event, callback, [ options ] ) → voidinheritedmodule:engine/model/documentselection~ModelDocumentSelection#listenTo:BASE_EMITTERRegisters a callback function to be executed when an event is fired in a specific (emitter) object.
Events can be grouped in namespaces using
:. When namespaced event is fired, it additionally fires all callbacks for that namespace.// myEmitter.on( ... ) is a shorthand for myEmitter.listenTo( myEmitter, ... ). myEmitter.on( 'myGroup', genericCallback ); myEmitter.on( 'myGroup:myEvent', specificCallback ); // genericCallback is fired. myEmitter.fire( 'myGroup' ); // both genericCallback and specificCallback are fired. myEmitter.fire( 'myGroup:myEvent' ); // genericCallback is fired even though there are no callbacks for "foo". myEmitter.fire( 'myGroup:foo' );Copy codeAn event callback can stop the event and set the return value of the
firemethod.Type parameters
Parameters
emitter : EmitterThe object that fires the event.
event : TEvent[ 'name' ]The name of the event.
callback : GetCallback<TEvent>The function to be called on event.
[ options ] : GetCallbackOptions<TEvent>Additional options.
Returns
void
observeMarkers( prefixOrName ) → voidmodule:engine/model/documentselection~ModelDocumentSelection#observeMarkersRegisters a marker group prefix or a marker name to be collected in the selection markers collection.
See also
MarkerCollection#getMarkersGroup().Parameters
prefixOrName : stringThe marker group prefix or marker name.
Returns
void
off( event, callback ) → voidinheritedmodule:engine/model/documentselection~ModelDocumentSelection#offStops executing the callback on the given event. Shorthand for
this.stopListening( this, event, callback ).Parameters
event : stringThe name of the event.
callback : FunctionThe function to stop being called.
Returns
void
on( event, callback, [ options ] ) → voidinheritedmodule:engine/model/documentselection~ModelDocumentSelection#onRegisters a callback function to be executed when an event is fired.
Shorthand for
this.listenTo( this, event, callback, options )(it makes the emitter listen on itself).Type parameters
Parameters
event : TEvent[ 'name' ]The name of the event.
callback : GetCallback<TEvent>The function to be called on event.
[ options ] : GetCallbackOptions<TEvent>Additional options.
Returns
void
once( event, callback, [ options ] ) → voidinheritedmodule:engine/model/documentselection~ModelDocumentSelection#onceRegisters a callback function to be executed on the next time the event is fired only. This is similar to calling
onfollowed byoffin the callback.Type parameters
Parameters
event : TEvent[ 'name' ]The name of the event.
callback : GetCallback<TEvent>The function to be called on event.
[ options ] : GetCallbackOptions<TEvent>Additional options.
Returns
void
refresh() → voidmodule:engine/model/documentselection~ModelDocumentSelection#refreshRefreshes selection attributes and markers according to the current position in the model.
Returns
void
stopDelegating( [ event ], [ emitter ] ) → voidinheritedmodule:engine/model/documentselection~ModelDocumentSelection#stopDelegatingStops delegating events. It can be used at different levels:
- To stop delegating all events.
- To stop delegating a specific event to all emitters.
- To stop delegating a specific event to a specific emitter.
Parameters
[ event ] : stringThe name of the event to stop delegating. If omitted, stops it all delegations.
[ emitter ] : Emitter(requires
event) The object to stop delegating a particular event to. If omitted, stops delegation ofeventto all emitters.
Returns
void
stopListening( [ emitter ], [ event ], [ callback ] ) → voidinheritedmodule:engine/model/documentselection~ModelDocumentSelection#stopListening:BASE_STOPStops listening for events. It can be used at different levels:
- To stop listening to a specific callback.
- To stop listening to a specific event.
- To stop listening to all events fired by a specific object.
- To stop listening to all events fired by all objects.
Parameters
[ emitter ] : EmitterThe object to stop listening to. If omitted, stops it for all objects.
[ event ] : string(Requires the
emitter) The name of the event to stop listening to. If omitted, stops it for all events fromemitter.[ callback ] : Function(Requires the
event) The function to be removed from the call list for the givenevent.
Returns
void
toJSON() → unknownmodule:engine/model/documentselection~ModelDocumentSelection#toJSONConverts
DocumentSelectionto plain object and returns it.Returns
unknownDocumentSelectionconverted to plain object.
_getStoredAttributes() → Iterable<tuple>internalmodule:engine/model/documentselection~ModelDocumentSelection#_getStoredAttributesReturns an iterable that iterates through all selection attributes stored in current selection's parent.
Returns
Iterable<tuple>
_overrideGravity() → stringinternalmodule:engine/model/documentselection~ModelDocumentSelection#_overrideGravityTemporarily changes the gravity of the selection from the left to the right.
The gravity defines from which direction the selection inherits its attributes. If it's the default left gravity, the selection (after being moved by the the user) inherits attributes from its left hand side. This method allows to temporarily override this behavior by forcing the gravity to the right.
It returns an unique identifier which is required to restore the gravity. It guarantees the symmetry of the process.
Returns
stringThe unique id which allows restoring the gravity.
Related:
_removeAttribute( key ) → voidinternalmodule:engine/model/documentselection~ModelDocumentSelection#_removeAttributeRemoves an attribute with given key from the selection. If the given attribute was set on the selection, fires the event-change:range event with removed attribute key. Should be used only within the
removeSelectionAttributemethod.Parameters
key : stringKey of the attribute to remove.
Returns
void
Related:
_restoreGravity( uid ) → voidinternalmodule:engine/model/documentselection~ModelDocumentSelection#_restoreGravityRestores the overridden gravity.
Restoring the gravity is only possible using the unique identifier returned by
_overrideGravity. Note that the gravity remains overridden as long as won't be restored the same number of times it was overridden.Parameters
uid : stringThe unique id returned by
_overrideGravity.
Returns
void
Related:
_setAttribute( key, value ) → voidinternalmodule:engine/model/documentselection~ModelDocumentSelection#_setAttributeSets attribute on the selection. If attribute with the same key already is set, it's value is overwritten. Should be used only within the
setSelectionAttributemethod.Parameters
key : stringKey of the attribute to set.
value : unknownAttribute value.
Returns
void
Related:
_setFocus( itemOrPosition, [ offset ] ) → voidinternalmodule:engine/model/documentselection~ModelDocumentSelection#_setFocusMoves
focusto the specified location. Should be used only within thesetSelectionFocusmethod.The location can be specified in the same form as writer.createPositionAt() parameters.
Parameters
itemOrPosition : ModelPosition | ModelItem[ offset ] : ModelPositionOffsetOffset or one of the flags. Used only when first parameter is a model item.
Returns
void
Related:
_setTo( args ) → voidinternalmodule:engine/model/documentselection~ModelDocumentSelection#_setToSets this selection's ranges and direction to the specified location based on the given selectable. Should be used only within the
setSelectionmethod.Parameters
args : tuple
Returns
void
Related:
Static methods
_getStoreAttributeKey( key ) → stringinternalstaticmodule:engine/model/documentselection~ModelDocumentSelection._getStoreAttributeKeyGenerates and returns an attribute key for selection attributes store, basing on original attribute key.
Parameters
key : stringAttribute key to convert.
Returns
stringConverted attribute key, applicable for selection store.
_isStoreAttributeKey( key ) → booleaninternalstaticmodule:engine/model/documentselection~ModelDocumentSelection._isStoreAttributeKeyChecks whether the given attribute key is an attribute stored on an element.
Parameters
key : string
Returns
boolean
Events
change( eventInfo, directChange = { [directChange.attributeKeys], directChange.directChange, [directChange.oldMarkers] } )module:engine/model/documentselection~ModelDocumentSelection#event:changeFired when selection range(s), attribute(s) or marker(s) changed.
Parameters
eventInfo : EventInfoAn object containing information about the fired event.
directChange : objectThis is always set to
falsein case ofchange:markerevent as there is no possibility to change markers directly throughModelDocumentSelectionAPI. See also event-change:range and event-change:attribute.Properties[ directChange.attributeKeys ] : Array<string>directChange.directChange : boolean[ directChange.oldMarkers ] : Array<Marker>
change:attribute( eventInfo, directChange = { directChange.attributeKeys, directChange.directChange } )module:engine/model/documentselection~ModelDocumentSelection#event:change:attributeFired when selection attribute changed.
Parameters
eventInfo : EventInfoAn object containing information about the fired event.
directChange : objectIn case of
ModelSelectionclass it is always set totruewhich indicates that the selection change was caused by a direct use of selection's API. TheModelDocumentSelection, however, may change because its attributes were directly changed through the writer or because its position was changed in the model and its attributes were refreshed (which means an indirect change). The indirect change does not occur in case of normal (detached) selections because they are "static" (as "not live") which mean that they are not updated once the document changes.PropertiesdirectChange.attributeKeys : Array<string>directChange.directChange : boolean
change:marker( eventInfo, directChange = { directChange.directChange, directChange.oldMarkers } )module:engine/model/documentselection~ModelDocumentSelection#event:change:markerFired when selection marker(s) changed.
Parameters
eventInfo : EventInfoAn object containing information about the fired event.
directChange : objectThis is always set to
falsein case ofchange:markerevent as there is no possibility to change markers directly throughModelDocumentSelectionAPI. See also event-change:range and event-change:attribute.PropertiesdirectChange.directChange : booleandirectChange.oldMarkers : Array<Marker>
change:range( eventInfo, directChange = { directChange.directChange } )module:engine/model/documentselection~ModelDocumentSelection#event:change:rangeFired when selection range(s) changed.
Parameters
eventInfo : EventInfoAn object containing information about the fired event.
directChange : objectIn case of
ModelSelectionclass it is always set totruewhich indicates that the selection change was caused by a direct use of selection's API. TheModelDocumentSelection, however, may change because its position was directly changed through the writer or because its position was changed because the structure of the model has been changed (which means an indirect change). The indirect change does not occur in case of normal (detached) selections because they are "static" (as "not live") which mean that they are not updated once the document changes.PropertiesdirectChange.directChange : boolean