How to use the roosterjs-editor-dom.Browser.isMac function in roosterjs-editor-dom

To help you get started, we’ve selected a few roosterjs-editor-dom 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-react / packages / roosterjs-react-editor / lib / components / LeanRooster.tsx View on Github external
private _getAnchorForClickOpenHyperlink(ev: React.MouseEvent, element: HTMLElement): HTMLAnchorElement {
        const { clickOpenHyperlinkViewMode, readonly } = this.props;
        const isPrimaryButton = ev.button === 0;
        if (!isPrimaryButton || !clickOpenHyperlinkViewMode || readonly || this.mode !== LeanRoosterModes.View) {
            return null;
        }

        // Hyperlink plugin will handle CTRL+Click when editor is created and FireFox will handle for contenteditable
        const ctrlOpen = Browser.isMac ? ev.metaKey : ev.ctrlKey;
        if ((this._editor && ctrlOpen) || (Browser.isFirefox && ctrlOpen)) {
            return null;
        }

        const anchor = findClosestElementAncestor(element, this._contentDiv, "a[href]");
        if (anchor) {
            return anchor as HTMLAnchorElement;
        }

        return null;
    }
github microsoft / roosterjs / publish / samplesite / scripts / controls / sidePane / formatState / FormatStatePane.tsx View on Github external
Browser
                        
                            {this.renderSpan(Browser.isChrome, 'Chrome')}
                            {this.renderSpan(Browser.isEdge, 'Edge')}
                            {this.renderSpan(Browser.isFirefox, 'Firefox')}
                            {this.renderSpan(Browser.isIE11OrGreater, 'IE10/11')}
                            {this.renderSpan(Browser.isIE, 'IE')}
                            {this.renderSpan(Browser.isIEOrEdge, 'IE/Edge')}
                            {this.renderSpan(Browser.isSafari, 'Safari')}
                            {this.renderSpan(Browser.isWebKit, 'Webkit')}
                        
                    
                    
                        OS
                        
                            {this.renderSpan(Browser.isMac, 'MacOS')}
                            {this.renderSpan(Browser.isWin, 'Windows')}
                        
                    
                    
                        User Agent
                        {window.navigator.userAgent}
                    
                    
                        App Version
                        {window.navigator.appVersion}
                    
                
            
        ) : (
            <div>Please focus into editor</div>
        );
github microsoft / roosterjs / packages / roosterjs-editor-plugins / lib / HyperLink / HyperLink.ts View on Github external
const anchor = this.editor.getElementAtCursor(
                'A',
                event.rawEvent.srcElement
            ) as HTMLAnchorElement;

            if (anchor) {
                if (this.onLinkClick) {
                    this.onLinkClick(anchor, event.rawEvent);
                    return;
                }

                let href: string;
                if (
                    !Browser.isFirefox &&
                    (href = this.tryGetHref(anchor)) &&
                    (Browser.isMac ? event.rawEvent.metaKey : event.rawEvent.ctrlKey)
                ) {
                    try {
                        const target = this.target || '_blank';
                        const window = this.editor.getDocument().defaultView;
                        window.open(href, target);
                    } catch {}
                }
            }
        }
    }
github microsoft / roosterjs / packages / roosterjs-editor-plugins / lib / ContentEdit / features / shortcutFeatures.ts View on Github external
        return key && commands.filter(cmd => (Browser.isMac ? cmd.macKey : cmd.winKey) == key)[0];
    });
github microsoft / roosterjs-react / packages / roosterjs-react-command-bar / lib / plugins / RoosterCommandBarPlugin.Shortcuts.ts View on Github external
export function getCommandFromEvent(event: PluginEvent): RoosterShortcutCommands {
    if (event.eventType !== PluginEventType.KeyDown) {
        return RoosterShortcutCommands.None;
    }

    const commands = Browser.isMac ? macCommands : winCommands;
    const keyboardEvent = (event as PluginDomEvent).rawEvent as KeyboardEvent;
    for (const cmd of commands) {
        if (
            !keyboardEvent.altKey &&
            cmd.ctrlKey === keyboardEvent.ctrlKey &&
            cmd.metaKey === keyboardEvent.metaKey &&
            cmd.shiftKey === keyboardEvent.shiftKey &&
            cmd.which === keyboardEvent.which
        ) {
            return cmd.command;
        }
    }

    return RoosterShortcutCommands.None;
}