<commit_before>import React, { Component } from "react";
import PropTypes from "prop-types";
import { Button, TextOverflowWrapper } from "@dnnsoftware/dnn-react-common";
import resx from "resources";
import "./fullEditor.less";

class FullEditor extends Component {
    constructor() {
        super();
        this.state = {
        };

        this.editorToolbar = [
            ["undo", "redo"],
            ["bold", "italic", "underline", "strikeThrough"],
            ["justifyLeft", "justifyCenter", "justifyRight", "justifyFull"],
            ["insertUnorderedList", "insertOrderedList"]
        ];
    }

    componentDidMount() {
        this.editorControl.focus();
    }

    execCommand(button, e) {
        this.editorControl.focus();
        document.execCommand(button, false, null);
        
        e.preventDefault();
    }

    onSave() {
        const { props } = this;

        if (typeof props.onChange === "function") {
            let content = this.editorControl.innerHTML;
            props.onChange(content);
        }
    }

    onCancel() {
        const { props } = this;

        props.onCancel();
    }

    /* eslint-disable react/no-danger */
    renderToolbar() {
        return (
            <div className='fulleditor-controls'>
                {
                    this.editorToolbar.map((group, i) => {
                        return <div className='btn-group' key={i}>
                            {
                                group.map((button, i) => {
                                    return (
                                        <a 
                                            className='btn' 
                                            data-role={button} 
                                            href='#'
                                            onClick={this.execCommand.bind(this, button)}
                                            dangerouslySetInnerHTML={{ __html: require("./icons/" + button + ".svg") }}
                                            key={i}>
                                        </a>
                                    );
                                })
                            }
                        </div>;
                    })
                }
            </div>
        );
    }

    /* eslint-disable react/no-danger */
    renderEditor() {
        const { props } = this;
        return (
            <div className='fulleditor-editor' 
                contentEditable
                ref={(e) => { this.editorControl = e; }}
                dangerouslySetInnerHTML={{ __html: props.value }}>
            </div>
        );
    }

    renderButtons() {
        return [
            <Button type="secondary" onClick={this.onCancel.bind(this)} key="first">
                <TextOverflowWrapper text={resx.get("Cancel") } maxWidth={100} />
            </Button>,
            <Button type="primary" onClick={this.onSave.bind(this)} key="second">
                <TextOverflowWrapper text={resx.get("Save") } maxWidth={100} />
            </Button>
        ];
    }

    render() {
        return (
            <div className="dnn-language-resource-full-editor">
                {this.renderToolbar()}
                {this.renderEditor()}
                {this.renderButtons()}
            </div>
        );
    }
}

FullEditor.propTypes = {
    value: PropTypes.string,
    onChange: PropTypes.func,
    className: PropTypes.string
};

FullEditor.defaultProps = {
};

export default FullEditor;
<commit_msg>Restores icons in language editor<commit_after>import React, { Component } from "react";
import PropTypes from "prop-types";
import { Button, TextOverflowWrapper } from "@dnnsoftware/dnn-react-common";
import resx from "resources";
import "./fullEditor.less";

class FullEditor extends Component {
    constructor() {
        super();
        this.state = {
        };

        this.editorToolbar = [
            ["undo", "redo"],
            ["bold", "italic", "underline", "strikeThrough"],
            ["justifyLeft", "justifyCenter", "justifyRight", "justifyFull"],
            ["insertUnorderedList", "insertOrderedList"]
        ];
    }

    componentDidMount() {
        this.editorControl.focus();
    }

    execCommand(button, e) {
        this.editorControl.focus();
        document.execCommand(button, false, null);
        
        e.preventDefault();
    }

    onSave() {
        const { props } = this;

        if (typeof props.onChange === "function") {
            let content = this.editorControl.innerHTML;
            props.onChange(content);
        }
    }

    onCancel() {
        const { props } = this;

        props.onCancel();
    }

    /* eslint-disable react/no-danger */
    renderToolbar() {
        return (
            <div className='fulleditor-controls'>
                {
                    this.editorToolbar.map((group, i) => {
                        return <div className='btn-group' key={i}>
                            {
                                group.map((button, i) => {
                                    return (
                                        <a 
                                            className='btn' 
                                            data-role={button} 
                                            href='#'
                                            onClick={this.execCommand.bind(this, button)}
                                            dangerouslySetInnerHTML={{ __html: require("./icons/" + button + ".svg").default }}
                                            key={i}>
                                        </a>
                                    );
                                })
                            }
                        </div>;
                    })
                }
            </div>
        );
    }

    /* eslint-disable react/no-danger */
    renderEditor() {
        const { props } = this;
        return (
            <div className='fulleditor-editor' 
                contentEditable
                ref={(e) => { this.editorControl = e; }}
                dangerouslySetInnerHTML={{ __html: props.value }}>
            </div>
        );
    }

    renderButtons() {
        return [
            <Button type="secondary" onClick={this.onCancel.bind(this)} key="first">
                <TextOverflowWrapper text={resx.get("Cancel") } maxWidth={100} />
            </Button>,
            <Button type="primary" onClick={this.onSave.bind(this)} key="second">
                <TextOverflowWrapper text={resx.get("Save") } maxWidth={100} />
            </Button>
        ];
    }

    render() {
        return (
            <div className="dnn-language-resource-full-editor">
                {this.renderToolbar()}
                {this.renderEditor()}
                {this.renderButtons()}
            </div>
        );
    }
}

FullEditor.propTypes = {
    value: PropTypes.string,
    onChange: PropTypes.func,
    className: PropTypes.string
};

FullEditor.defaultProps = {
};

export default FullEditor;

{'fraction_non_alphanumeric': 0.12521270561542824, 'fraction_numerical': 0.0017016449234259785, 'mean_word_length': 1.2179245283018867, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '540127', 'n_tokens_mistral': 1736, 'n_tokens_neox': 1684, 'n_words': 304}