How to use the roosterjs-editor-plugins.getDefaultContentEditFeatures function in roosterjs-editor-plugins

To help you get started, we’ve selected a few roosterjs-editor-plugins 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 / publish / samplesite / scripts / updateSampleCode.ts View on Github external
function assemblePluginsString(plugins: EditorPlugin[], features: ContentEditFeatures): string {
    if (plugins) {
        let contentEditOptions = '';
        let pluginsString = '';

        if (features) {
            pluginsString += 'var options = roosterjsPlugins.getDefaultContentEditFeatures();\n';
            let defaultFeatures = getDefaultContentEditFeatures();
            for (let key of Object.keys(defaultFeatures)) {
                if (key != 'smartOrderedListStyles' && features[key] != defaultFeatures[key]) {
                    pluginsString += 'options.' + key + ' = ' + (features[key] ? 'true' : 'false') + ';\n';
                }
            }
            contentEditOptions += '  new roosterjsPlugins.ContentEdit(options),\n';
        } else {
            contentEditOptions = '  new roosterjsPlugins.ContentEdit(),\n';
        }

        pluginsString += 'var plugins = [\n';
        plugins.forEach(plugin => {
            if (plugin instanceof Watermark) {
                pluginsString += "  new roosterjsPlugins.Watermark('Type content here...'),\n";
            } else if (plugin instanceof ImageResize) {
                pluginsString += '  new roosterjsImageResizePlugin.ImageResize(),\n';
github microsoft / roosterjs / publish / samplesite / scripts / initOptions.ts View on Github external
features.indentWhenTab = (document.getElementById('indentWhenTabCheckbox') as HTMLInputElement).checked;
        features.outdentWhenShiftTab = (document.getElementById('outdentWhenShiftTabCheckbox') as HTMLInputElement).checked;
        features.outdentWhenBackspaceOnEmptyFirstLine = (document.getElementById('outdentWhenBackspaceOnEmptyFirstLineCheckbox') as HTMLInputElement).checked;
        features.outdentWhenEnterOnEmptyLine = (document.getElementById('outdentWhenEnterOnEmptyLineCheckbox') as HTMLInputElement).checked;
        features.mergeInNewLineWhenBackspaceOnFirstChar = (document.getElementById('mergeInNewLineWhenBackspaceOnFirstCharCheckbox') as HTMLInputElement).checked;
        features.unquoteWhenBackspaceOnEmptyFirstLine = (document.getElementById('unquoteWhenBackspaceOnEmptyFirstLineCheckbox') as HTMLInputElement).checked;
        features.unquoteWhenEnterOnEmptyLine = (document.getElementById('unquoteWhenEnterOnEmptyLineCheckbox') as HTMLInputElement).checked;
        features.autoBullet = (document.getElementById('autoBulletCheckbox') as HTMLInputElement).checked;
        features.tabInTable = (document.getElementById('tabInTableCheckbox') as HTMLInputElement).checked;
        features.upDownInTable = (document.getElementById('upDownInTableCheckbox') as HTMLInputElement).checked;
        features.unlinkWhenBackspaceAfterLink = (document.getElementById('unlinkWhenBackspaceAfterLinkCheckbox') as HTMLInputElement).checked;
        features.defaultShortcut = (document.getElementById('defaultShortcutCheckbox') as HTMLInputElement).checked;
        features.smartOrderedList = (document.getElementById('smartOrderedListCheckbox') as HTMLInputElement).checked;
        plugins.push(new ContentEdit(features));

        let defaultFeatures = getDefaultContentEditFeatures();
        let keys = Object.keys(defaultFeatures);
        for (let key of keys) {
            if (key != 'smartOrderedListStyles' && features[key] != defaultFeatures[key]) {
                featuresChanged = true;
                break;
            }
        }
    }

    if ((document.getElementById('watermarkCheckbox') as HTMLInputElement).checked) {
        plugins.push(new Watermark('Type content here...'));
    }

    if ((document.getElementById('imageResizeCheckbox') as HTMLInputElement).checked) {
        plugins.push(new ImageResize());
    }
github microsoft / roosterjs / publish / samplesite / scripts / controls / editor / Editor.tsx View on Github external
private getContentEditOptions(): ContentEditFeatures {
        let defaultFeatures = getDefaultContentEditFeatures();
        return assign(defaultFeatures, this.state.contentEditFeatures);
    }
}
github microsoft / roosterjs / publish / samplesite / scripts / initOptions.ts View on Github external
export function initEditorForOptions() {
    setCurrentEditor(null);

    let plugins: EditorPlugin[] = [];
    if ((document.getElementById('hyperlinkCheckbox') as HTMLInputElement).checked) {
        plugins.push(new HyperLink());
    }
    if ((document.getElementById('pasteCheckbox') as HTMLInputElement).checked) {
        plugins.push(new Paste());
    }

    let features = getDefaultContentEditFeatures();
    let featuresChanged = false;

    if ((document.getElementById('contentEditCheckbox') as HTMLInputElement).checked) {
        features.autoLink = (document.getElementById('autoLinkCheckbox') as HTMLInputElement).checked;
        features.indentWhenTab = (document.getElementById('indentWhenTabCheckbox') as HTMLInputElement).checked;
        features.outdentWhenShiftTab = (document.getElementById('outdentWhenShiftTabCheckbox') as HTMLInputElement).checked;
        features.outdentWhenBackspaceOnEmptyFirstLine = (document.getElementById('outdentWhenBackspaceOnEmptyFirstLineCheckbox') as HTMLInputElement).checked;
        features.outdentWhenEnterOnEmptyLine = (document.getElementById('outdentWhenEnterOnEmptyLineCheckbox') as HTMLInputElement).checked;
        features.mergeInNewLineWhenBackspaceOnFirstChar = (document.getElementById('mergeInNewLineWhenBackspaceOnFirstCharCheckbox') as HTMLInputElement).checked;
        features.unquoteWhenBackspaceOnEmptyFirstLine = (document.getElementById('unquoteWhenBackspaceOnEmptyFirstLineCheckbox') as HTMLInputElement).checked;
        features.unquoteWhenEnterOnEmptyLine = (document.getElementById('unquoteWhenEnterOnEmptyLineCheckbox') as HTMLInputElement).checked;
        features.autoBullet = (document.getElementById('autoBulletCheckbox') as HTMLInputElement).checked;
        features.tabInTable = (document.getElementById('tabInTableCheckbox') as HTMLInputElement).checked;
        features.upDownInTable = (document.getElementById('upDownInTableCheckbox') as HTMLInputElement).checked;
        features.unlinkWhenBackspaceAfterLink = (document.getElementById('unlinkWhenBackspaceAfterLinkCheckbox') as HTMLInputElement).checked;
        features.defaultShortcut = (document.getElementById('defaultShortcutCheckbox') as HTMLInputElement).checked;