How to use the roosterjs-editor-api.createLink function in roosterjs-editor-api

To help you get started, we’ve selected a few roosterjs-editor-api 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-command-bar / lib / components / LinkDialog.tsx View on Github external
private insertLink = (): void => {
        const { editor, selectionRange } = this.props;

        if (!this.linkField || !editor || editor.isDisposed()) {
            return;
        }

        editor && !editor.isDisposed() && editor.select(selectionRange);
        this.linkInserted = true; // don't need to restore the selection after dismiss if we're changing selection into a link
        createLink(editor, this.linkField.value);
        this.dismissDialog();
    };
github microsoft / roosterjs / publish / samplesite / scripts / controls / ribbon / renderInsertLinkDialog.tsx View on Github external
private onOk = () => {
        this.props.onDismiss();
        createLink(this.props.editor, this.txtUrl.value, null, this.txtDisplayText.value);
    };
}
github microsoft / roosterjs / sample / scripts / initFormatBar.ts View on Github external
document.getElementById('insertLink').addEventListener('click', function() {
        let editor = getCurrentEditor();
        let range = editor.getSelectionRange();
        let existingLink = queryNodesWithSelection(editor, 'a[href]')[0] as HTMLAnchorElement;
        let url = window.prompt('Url', existingLink ? existingLink.href : 'http://');
        let text = range.collapsed && !existingLink ? window.prompt('Text of link', url) : null;
        createLink(editor, url, url, text);
    });
github microsoft / roosterjs-react / packages / roosterjs-react-common / lib / utils / createLinkWithPrompt.ts View on Github external
export default function createLinkWithPrompt(editor: Editor, strings: Strings): void {
    if (!editor || editor.isDisposed()) {
        return;
    }

    let message = "Enter address";
    if (strings) {
        message = strings[CreateLinkWithPromptStringKey] || message;
    }

    const link = prompt(message);
    if (link) {
        createLink(editor, link);
    }
}
github microsoft / roosterjs-react / packages / roosterjs-react-ribbon / lib / components / buttons.tsx View on Github external
).then(link => {
            if (link) {
                editor.focus();
                createLink(editor, link, link);
            }
        });
    },