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/ciruiteditor/lineeditor/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/libs/absol-form/js/ciruiteditor/lineeditor/LineEditorCmd.js
import {vScrollIntoView} from "absol-acomp/js/utils";
import LELine from "./LELine";

var LineEditorCmd = {};

LineEditorCmd.preview = function () {
    this.layoutEditor.execCmd('preview');
};

LineEditorCmd.delete = function () {
    var lines = this.activatedLines.slice();
    for (var i = 0; i < lines.length; ++i) {
        this.deleteLine(lines[i]);
    }
};

LineEditorCmd.copy = function () {
    this.setClipboardLines(this.activatedLines);
};

LineEditorCmd.save = function () {
    this.layoutEditor.execCmd('save');
};

LineEditorCmd.paste = function () {
    var rawLines = this.getClipboardLines();
    if (!rawLines) return;
    var self = this;
    var pointList = this.getPointList();
    var pointDict = this.getPointDict();
    rawLines.forEach(function (rawBlock, i) {
        var line = new LELine(this);
        line.loadPoints(pointList, pointDict);
        line.on('select', function (event) {
            if (self.isActivatedLine(line)) {
                if (event.shiftKey && self.activatedBlocks.length > 1) {
                    self.deactivateLine(line);
                }
                else self.activateLine(line);
            }
            else {
                self.activateLine(line, event.shiftKey);
            }
        });
        this.$body.addChild(line.getView());
        this.lines.push(line);
        if (i + 1 === rawLines.length)
            vScrollIntoView(line.getView());
        line.setData(rawBlock);
        self.activateLine(line, i > 0);
    }.bind(this));
    this.notifyUnsaved();
};


LineEditorCmd.insert_line = function () {
    var self = this;
    var line = new LELine(this);
    var pointList = this.getPointList();
    var pointDict = this.getPointDict();
    line.loadPoints(pointList, pointDict);
    line.on('select', function (event) {
        if (self.isActivatedLine(line)) {
            if (event.shiftKey && self.activatedBlocks.length > 1) {
                self.deactivateLine(line);
            }
            else self.activateLine(line);
        }
        else {
            self.activateLine(line, event.shiftKey);
        }
    });
    this.$body.addChild(line.getView());
    this.lines.push(line);
    vScrollIntoView(line.getView());
    line.setData({});
    this.activateLine(line);
};


export var LineEditorCmdTree = [
    ['preview'],
    ['save'],
    [
        // 'cut',
        'copy',
        'paste',
        'delete'
    ],
    [
        'insert_line'
    ]
];

export var LineEditorCmdDescriptors = {
    preview: {
        type: 'trigger',
        icon: 'span.mdi.mdi-play',
        desc: 'Preview',
        bindKey: { win: 'Ctrl-K', mac: 'TODO?' }

    },
    save: {
        type: 'trigger',
        icon: 'span.mdi.mdi-content-save',
        desc: 'Save',
        bindKey: { win: 'Ctrl-S', mac: '//todo' }
    },
    cut: {
        type: 'trigger',
        icon: 'span.mdi.mdi-content-cut',
        desc: 'Cut',
        bindKey: { win: 'Ctrl-X', mac: 'TODO?' }
    },
    copy: {
        type: 'trigger',
        icon: 'span.mdi.mdi-content-copy',
        desc: 'Copy',
        bindKey: { win: 'Ctrl-C', mac: 'TODO?' }
    },
    paste: {
        type: 'trigger',
        icon: 'span.mdi.mdi-content-paste',
        desc: 'Paste',
        bindKey: { win: 'Ctrl-V', mac: 'TODO?' }
    },
    delete: {
        type: 'trigger',
        icon: 'span.mdi.mdi-delete-variant',
        desc: 'Delete',
        bindKey: { win: 'Delete', mac: 'Delete' }
    },
    insert_line: {
        type: 'trigger',
        icon: 'span.mdi.mdi-relation-one-to-one',
        desc: 'Insert Line',
    }
};

export default LineEditorCmd;

VaKeR 2022