How to use the roosterjs-editor-types.Alignment.Center 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-api / lib / format / setAlignment.ts View on Github external
export default function setAlignment(editor: Editor, alignment: Alignment) {
    let command = DocumentCommand.JustifyLeft;
    let align = 'left';

    if (alignment == Alignment.Center) {
        command = DocumentCommand.JustifyCenter;
        align = 'center';
    } else if (alignment == Alignment.Right) {
        command = DocumentCommand.JustifyRight;
        align = 'right';
    }

    editor.addUndoSnapshot(() => {
        execCommand(editor, command);
        editor.queryElements(
            '[align]',
            QueryScope.OnSelection,
            node => (node.style.textAlign = align)
        );
    }, ChangeSource.Format);
}
github microsoft / roosterjs / sample / scripts / initFormatBar.ts View on Github external
document.getElementById('alignCenterButton').addEventListener('click', function() {
        setAlignment(getCurrentEditor(), Alignment.Center);
    });