How to use the roosterjs-editor-types.PluginEventType.MouseDown function in roosterjs-editor-types

To help you get started, we’ve selected a few roosterjs-editor-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / roosterjs / packages / roosterjs-editor-core / lib / editor / Editor.ts View on Github external
private createEventHandlers() {
        this.eventDisposers = [
            attachDomEvent(this.core, 'input', null, this.stopPropagation),
            attachDomEvent(this.core, 'keypress', PluginEventType.KeyPress, this.onKeyPress),
            attachDomEvent(this.core, 'keydown', PluginEventType.KeyDown, this.stopPropagation),
            attachDomEvent(this.core, 'keyup', PluginEventType.KeyUp, this.stopPropagation),
            attachDomEvent(this.core, 'mousedown', PluginEventType.MouseDown),
            attachDomEvent(this.core, 'mouseup', PluginEventType.MouseUp),
            attachDomEvent(this.core, 'compositionstart', null, () => (this.inIME = true)),
            attachDomEvent(
                this.core,
                'compositionend',
                PluginEventType.CompositionEnd,
                () => (this.inIME = false)
            ),
            attachDomEvent(this.core, 'focus', null, () => {
                // Restore the last saved selection first
                if (this.core.cachedSelectionRange && !this.disableRestoreSelectionOnFocus) {
                    restoreSelection(this.core);
                }
                this.core.cachedSelectionRange = null;
            }),
            attachDomEvent(this.core, IS_IE_OR_EDGE ? 'beforedeactivate' : 'blur', null, () => {
github microsoft / roosterjs / packages / roosterjs-editor-core / lib / coreAPI / createEventHandlers.ts View on Github external
if (!core.cachedSelectionRange) {
                          saveSelectionRange(core);
                      }
                  }
        ),
        new DOMEventHandler(core, 'keypress', PluginEventType.KeyPress, event => onKeyPress(core, event as KeyboardEvent)),
        new DOMEventHandler(core, 'keydown', PluginEventType.KeyDown),
        new DOMEventHandler(core, 'keyup', PluginEventType.KeyUp),
        new DOMEventHandler(core, 'compositionstart', null, () => (core.isInIME = true)),
        new DOMEventHandler(
            core,
            'compositionend',
            PluginEventType.CompositionEnd,
            () => (core.isInIME = false)
        ),
        new DOMEventHandler(core, 'mousedown', PluginEventType.MouseDown),
        new DOMEventHandler(core, 'mouseup', PluginEventType.MouseUp),
        new DOMEventHandler(core, 'mouseover', PluginEventType.MouseOver),
        new DOMEventHandler(core, 'mouseout', PluginEventType.MouseOut),
        new DOMEventHandler(core, 'paste', PluginEventType.Paste),
        new DOMEventHandler(core, 'copy', PluginEventType.Copy, () => {}),
        new DOMEventHandler(core, 'focus', PluginEventType.Focus, () => {
            // Restore the last saved selection first
            if (core.cachedSelectionRange && !core.disableRestoreSelectionOnFocus) {
                restoreSelection(core);
            }

            core.cachedSelectionRange = null;
        }),
    ];

    if (isIEorEdge) {
github microsoft / roosterjs / packages / roosterjs-editor-core / lib / corePlugins / MouseUpPlugin.ts View on Github external
onPluginEvent(event: PluginEvent) {
        if (event.eventType == PluginEventType.MouseDown && !this.mouseUpEventListerAdded) {
            this.editor
                .getDocument()
                .addEventListener('mouseup', this.onMouseUp, true /*setCapture*/);
            this.mouseUpEventListerAdded = true;
        }
    }
github microsoft / roosterjs / publish / samplesite / scripts / controls / sidePane / eventViewer / EventViewPane.tsx View on Github external
private renderEvent(event: PluginEvent): JSX.Element {
        switch (event.eventType) {
            case PluginEventType.KeyDown:
            case PluginEventType.KeyPress:
            case PluginEventType.KeyUp:
                return (
                    <span>
                        Key=
                        {event.rawEvent.which}
                    </span>
                );

            case PluginEventType.MouseDown:
            case PluginEventType.MouseUp:
                return (
                    <span>
                        Button=
                        {event.rawEvent.button}, SrcElement=
                        {event.rawEvent.target &amp;&amp; getTagOfNode(event.rawEvent.target as Node)},
                        PageX=
                        {event.rawEvent.pageX}, PageY=
                        {event.rawEvent.pageY}
                    </span>
                );

            case PluginEventType.ContentChanged:
                return (
                    <span>
                        Source=
</span>
github microsoft / roosterjs / packages / roosterjs-editor-core / lib / corePlugins / EditPlugin.ts View on Github external
onPluginEvent(event: PluginEvent) {
        let contentChanged = false;
        let currentFeature = this.findFeature(event);

        switch (event.eventType) {
            case PluginEventType.ContentChanged:
                contentChanged = this.autoCompleteChangeSource != event.source;
                break;
            case PluginEventType.MouseDown:
            case PluginEventType.KeyDown:
                contentChanged = true;
                break;
        }

        if (currentFeature) {
            currentFeature.handleEvent(event, this.editor);
        }

        if (contentChanged) {
            this.autoCompleteSnapshot = null;
            this.autoCompleteChangeSource = null;
        }
    }
github microsoft / roosterjs-react / packages / roosterjs-react-command-bar / lib / plugins / RoosterCommandBarPlugin.ts View on Github external
import { Editor, EditorPlugin, browserData } from 'roosterjs-editor-core';
import { PluginEvent, PluginEventType, PluginDomEvent } from 'roosterjs-editor-types';
import { DefaultShortcut } from 'roosterjs-editor-plugins';
import { KeyCodes } from 'office-ui-fabric-react/lib/Utilities';
import { createLinkWithPrompt } from 'roosterjs-react-common';

import RoosterCommandBar from '../components/RoosterCommandBar';
import RoosterCommandBarPluginInterface from '../schema/RoosterCommandBarPluginInterface';

export default class RoosterCommandBarPlugin implements EditorPlugin, RoosterCommandBarPluginInterface {
    private static readonly EventTypesToHandle: { [eventType: number]: boolean } = {
        [PluginEventType.KeyUp]: true,
        [PluginEventType.MouseDown]: true,
        [PluginEventType.MouseUp]: true,
        [PluginEventType.ContentChanged]: true
    };

    private editor: Editor;
    private commandBars: RoosterCommandBar[] = [];
    private defaultShortcut: DefaultShortcut = new DefaultShortcut();
    private strings: { [key: string]: string };

    constructor(strings?: { [key: string]: string }) {
        this.strings = strings;
    }

    public initialize(editor: Editor): void {
        this.defaultShortcut.initialize(editor);
        this.editor = editor;