VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/libs/absol-form/js/components/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/libs/absol-form/js/components/CKEditor.js
import ScalableComponent from "../core/ScalableComponent";
import {$, _} from '../core/FCore';
import {AssemblerInstance} from "../core/Assembler";
import ResizeSystem from "absol/src/HTML5/ResizeSystem";
import inheritComponentClass from "../core/inheritComponentClass";

/***
 * @extends ScalableComponent
 * @constructor
 */
function CKEditor() {
    ScalableComponent.call(this);
    this.style.width = 600;
    this.style.height = 'auto';
    this.editior = null;
    this._pendingData = null;
}

inheritComponentClass(CKEditor, ScalableComponent);

CKEditor.prototype.menuIcon = 'span.mdi.mdi-file-word-box';
CKEditor.prototype.tag = 'CKEditor';

CKEditor.prototype.render = function () {
    return _({
        class: 'as-ckeditor-wrapper',
        child: [
            '.as-ckeditor-place-holder',
            'attachhook'
        ]
    });
};

CKEditor.prototype.onCreated = function () {
    this.$placeHolder = $('.as-ckeditor-place-holder', this.domElt);
    this.$attachhook = $('attachhook', this.domElt);
    this.$attachhook.once('attached', this._placeEditor.bind(this));
    this.$attachhook.requestUpdateSize = this.requestUpdateSize.bind(this);
    ResizeSystem.add(this.$attachhook);
};

CKEditor.prototype._placeEditor = function () {
    var config = {};
    if (this.style.height === 'auto') {
        config.extraPlugins = 'autogrow';
    }
    this.makeConfig(config);
    if (window.CKEDITOR) {
        this.editor = CKEDITOR.replace(this.$placeHolder, config);
        this.setupEditor();
        if (this._pendingData) {
            this.editor.setData(this._pendingData);
            this._pendingData = null;
        }
    } else {
        this.domElt.addChild(_({text: 'Please install CKEDITOR in your website!'}))
    }
};


CKEditor.prototype.requestUpdateSize = function () {
    if (this.editor) {
        var b = this.domElt.getBoundingClientRect();
        try {
            this.editor.resize(typeof this.style.width === "number" ? this.style.width : null, typeof this.style.height === "number" ? this.style.height : b.height)
        } catch (err) {
        }
    }
};

CKEditor.prototype.setupEditor = function () {
    this.editor.on('instanceReady', this.requestUpdateSize.bind(this))
    this.editor.on('change', function () {
        this.pinFire('data');
    }.bind(this));
};

CKEditor.prototype.makeConfig = function (config) {
    config.toolbar = [
        {
            name: 'mode',
            groups: ['mode', 'document', 'doctools'],
            items: ['Source', '-', 'ExportPdf', 'Preview', 'Print', '-', 'Templates']
        },
        {
            name: 'clipboard',
            groups: ['clipboard', 'undo'],
            items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']
        },
        {
            name: 'editing',
            groups: ['find', 'selection', 'spellchecker'],
            items: ['Find', 'Replace', '-', 'SelectAll', '-', 'Scayt']
        },
        '/',
        {
            name: 'basicstyles',
            groups: ['basicstyles', 'cleanup'],
            items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'CopyFormatting', 'RemoveFormat']
        },
        {
            name: 'paragraph',
            groups: ['list', 'indent', 'blocks', 'align', 'bidi'],
            items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 'Language']
        },
        {name: 'links', items: ['Link', 'Unlink', 'Anchor']},
        {name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak']},
        '/',
        {name: 'styles', items: ['Styles', 'Format', 'Font', 'FontSize']},
        {name: 'colors', items: ['TextColor', 'BGColor']},
        {name: 'tools', items: ['Maximize', 'ShowBlocks']},
        {name: 'others', items: ['-']},
        {name: 'about', items: ['About']}
    ];
    return config;
};

CKEditor.prototype.dataImplicit = function (data) {
    return data;
};

CKEditor.prototype.dataExplicit = function (data) {
    return data;
};


CKEditor.prototype.pinHandlers.data = {
    get: function () {
        return this.attributes.data;
    },
    receives: function (value) {
        this.attributes.data = value;
    },
    descriptor: {
        type: 'text'
    }
};

CKEditor.prototype.attributeHandlers.data = {
    set: function (value) {
        value = this.dataImplicit(value);
        var prevData = this.editor ? this.editor.getData() : this._pendingData;
        prevData = prevData || '';
        if (value !== prevData) {
            if (this.editor) {
                this.editor.setData(value);
            } else {
                this._pendingData = value;
            }
            this.pinFire('data');
        }
    },
    get: function () {
        return this.editor ? this.dataExplicit(this.editor.getData()) : this._pendingData;
    },
    descriptor: {
        type: 'text'
    }
};

CKEditor.prototype.createDataBindingDescriptor = function () {
    var thisC = this;
    return {
        configurable: true,
        set: function (value) {
            thisC.setAttribute('data', value);
        },
        get: function () {
            return thisC.getAttribute('data');
        }
    }
};

AssemblerInstance.addClass(CKEditor);


export default CKEditor;

VaKeR 2022