Trilium Frontend API
    Preparing search index...

    Class InputObserver

    Observer for events connected with data input.

    Note: This observer is attached by module:engine/view/view~EditingView and available by default in all editor instances.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    document: ViewDocument

    A reference to the module:engine/view/document~ViewDocument object.

    domEventType: "beforeinput"
    useCapture: boolean

    If set to true DOM events will be listened on the capturing phase. Default value is false.

    usePassive: boolean

    If set to true, indicates that the function specified by listener will never call preventDefault(). Default value is false.

    An instance of the view controller.

    Accessors

    • get isEnabled(): boolean

      The state of the observer. If it is disabled, no events will be fired.

      Returns boolean

    Methods

    • Checks whether a given DOM event should be ignored (should not be turned into a synthetic view document event).

      Currently, an event will be ignored only if its target or any of its ancestors has the data-cke-ignore-events attribute. This attribute can be used inside the structures generated by module:engine/view/downcastwriter~ViewDowncastWriter#createUIElement ViewDowncastWriter#createUIElement() to ignore events fired within a UI that should be excluded from CKEditor 5's realms.

      Parameters

      • domTarget: Node

        The DOM event target to check (usually an element, sometimes a text node and potentially sometimes a document, too).

      Returns boolean

      Whether this event should be ignored by the observer.

    • Delegates selected events to another module:utils/emittermixin~Emitter. For instance:

      emitterA.delegate( 'eventX' ).to( emitterB );
      emitterA.delegate( 'eventX', 'eventY' ).to( emitterC );

      then eventX is delegated (fired by) emitterB and emitterC along with data:

      emitterA.fire( 'eventX', data );
      

      and eventY is delegated (fired by) emitterC along with data:

      emitterA.fire( 'eventY', data );
      

      Parameters

      • ...events: string[]

        Event names that will be delegated to another emitter.

      Returns EmitterMixinDelegateChain

    • Disables and destroys the observer, among others removes event listeners created by the observer.

      Returns void

    • Disables the observer. This method is called before module:engine/view/view~EditingView#forceRender rendering to prevent firing events during rendering.

      Returns void

      module:engine/view/observer/observer~Observer#enable

    • Enables the observer. This method is called when the observer is registered to the module:engine/view/view~EditingView and after module:engine/view/view~EditingView#forceRender rendering (all observers are #disable disabled before rendering).

      A typical use case for disabling observers is that mutation observers need to be disabled for the rendering. However, a child class may not need to be disabled, so it can implement an empty method.

      Returns void

      module:engine/view/observer/observer~Observer#disable

    • Calls Document#fire() if observer #isEnabled is enabled.

      Parameters

      • eventType: string | EventInfo<string, unknown>

        The event type (name).

      • domEvent: Event

        The DOM event.

      • OptionaladditionalData: object

        The additional data which should extend the module:engine/view/observer/domeventdata~ViewDocumentDomEventData event data object.

      Returns void

      module:utils/emittermixin~Emitter#fire

    • Registers a callback function to be executed when an event is fired in a specific Emitter or DOM Node. It is backwards compatible with module:utils/emittermixin~Emitter#listenTo.

      Type Parameters

      Parameters

      • emitter: Node | EventTarget | Window

        The object that fires the event.

      • event: K

        The name of the event.

      • callback: (this: this, ev: EventInfo, event: DomEventMap[K]) => void

        The function to be called on event.

      • Optionaloptions: CallbackOptions & { useCapture?: boolean; usePassive?: boolean }

        Additional options.

        • Optional ReadonlyuseCapture?: boolean

          Indicates that events of this type will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree.

        • Optional ReadonlyusePassive?: boolean

          Indicates that the function specified by listener will never call preventDefault() and prevents blocking browser's main thread by this event handler.

      Returns void

      HTML_EMITTER

    • Registers 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' );

      An event callback can module:utils/eventinfo~EventInfo#stop stop the event and set the module:utils/eventinfo~EventInfo#return return value of the #fire method.

      Type Parameters

      • TEvent extends BaseEvent

        The type describing the event. See module:utils/emittermixin~BaseEvent.

      Parameters

      Returns void

      DOM_EMITTER

    • Starts observing given DOM element.

      Parameters

      Returns void

    • Stops executing the callback on the given event. Shorthand for #stopListening this.stopListening( this, event, callback ).

      Parameters

      • event: string

        The name of the event.

      • callback: Function

        The function to stop being called.

      Returns void

    • Registers a callback function to be executed when an event is fired.

      Shorthand for #listenTo this.listenTo( this, event, callback, options ) (it makes the emitter listen on itself).

      Type Parameters

      • TEvent extends BaseEvent

        The type descibing the event. See module:utils/emittermixin~BaseEvent.

      Parameters

      Returns void

    • Registers a callback function to be executed on the next time the event is fired only. This is similar to calling #on followed by #off in the callback.

      Type Parameters

      • TEvent extends BaseEvent

        The type descibing the event. See module:utils/emittermixin~BaseEvent.

      Parameters

      Returns void

    • Callback which should be called when the DOM event occurred. Note that the callback will not be called if observer #isEnabled is not enabled.

      Parameters

      Returns void

      #domEventType

    • Stops 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

      • Optionalevent: string

        The name of the event to stop delegating. If omitted, stops it all delegations.

      • Optionalemitter: Emitter

        (requires event) The object to stop delegating a particular event to. If omitted, stops delegation of event to all emitters.

      Returns void

    • Stops listening for events. It can be used at different levels: It is backwards compatible with module:utils/emittermixin~Emitter#listenTo.

      • 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

      • Optionalemitter: Node | EventTarget | Emitter | Window

        The object to stop listening to. If omitted, stops it for all objects.

      • Optionalevent: string

        (Requires the emitter) The name of the event to stop listening to. If omitted, stops it for all events from emitter.

      • Optionalcallback: Function

        (Requires the event) The function to be removed from the call list for the given event.

      Returns void

      DOM_STOP

    • Stops observing given DOM element.

      Parameters

      Returns void