bindToElement() {
        this.element.classList.add('layouteer-editor');
        this.element.tabIndex = 1;
        // event handlers
        this.bindEventHandlers();
        // draw ruler
        const ruler = document.createElement('div');
        ruler.classList.add('ruler');
        ruler.innerHTML = Layouteer.generateRuler(this.layouteer.columnsCount, this.layouteer.columnSize).split(' ').join('&nbsp;');
        this.element.appendChild(ruler);
        // draw centent
        for (let i = 0; i < this.index.length; i++) {
            const idxRow = this.index[i];
            const row = document.createElement('div');
            this.element.appendChild(row);
            for (let j = 0; j < idxRow.length; j++) {
                const ch = this.layouteer.content[i * idxRow.length + i + j];
                const cell = document.createElement('span');
                cell.innerHTML = ch != ' ' ? ch : '&nbsp;';
                row.appendChild(cell);
                const leftIdxItem = j > 0 ? this.index[i][j - 1] : undefined;
                const topIdxItem = i > 0 ? this.index[i - 1][j] : undefined;
                const currentIdxItem = this.index[i][j] = new LayouteerEditorCell({
                    el: cell,
                    rowEl: row,
                    row: i,
                    column: j,
                    left: leftIdxItem,
                    top: topIdxItem,
                    right: undefined,
                    bottom: undefined,
                    line: undefined
                });
                cell._index = currentIdxItem;
                if (leftIdxItem) {
                    leftIdxItem.right = currentIdxItem;
                }
                if (topIdxItem) {
                    topIdxItem.bottom = currentIdxItem;
                }
            }
        }
        this.__buildLineIndex__();
        // set cursor
        this.setCursor(this.index[0][0]);
    }
/**
     * Bind editor to given HTML element, create content and bind handlers
     */
Bind editor to given HTML element, create content and bind handlers
Bind editor to given HTML element create content and bind handlers
bindToElement() {
        this.element.classList.add('layouteer-editor');
        this.element.tabIndex = 1;
        this.bindEventHandlers();
        const ruler = document.createElement('div');
        ruler.classList.add('ruler');
        ruler.innerHTML = Layouteer.generateRuler(this.layouteer.columnsCount, this.layouteer.columnSize).split(' ').join('&nbsp;');
        this.element.appendChild(ruler);
        for (let i = 0; i < this.index.length; i++) {
            const idxRow = this.index[i];
            const row = document.createElement('div');
            this.element.appendChild(row);
            for (let j = 0; j < idxRow.length; j++) {
                const ch = this.layouteer.content[i * idxRow.length + i + j];
                const cell = document.createElement('span');
                cell.innerHTML = ch != ' ' ? ch : '&nbsp;';
                row.appendChild(cell);
                const leftIdxItem = j > 0 ? this.index[i][j - 1] : undefined;
                const topIdxItem = i > 0 ? this.index[i - 1][j] : undefined;
                const currentIdxItem = this.index[i][j] = new LayouteerEditorCell({
                    el: cell,
                    rowEl: row,
                    row: i,
                    column: j,
                    left: leftIdxItem,
                    top: topIdxItem,
                    right: undefined,
                    bottom: undefined,
                    line: undefined
                });
                cell._index = currentIdxItem;
                if (leftIdxItem) {
                    leftIdxItem.right = currentIdxItem;
                }
                if (topIdxItem) {
                    topIdxItem.bottom = currentIdxItem;
                }
            }
        }
        this.__buildLineIndex__();
        this.setCursor(this.index[0][0]);
    }
bindToElement ( ) { this . element . classList . add ( 'layouteer-editor' ) ; this . element . tabIndex = 1 ; this . bindEventHandlers ( ) ; const ruler = document . createElement ( 'div' ) ; ruler . classList . add ( 'ruler' ) ; ruler . innerHTML = Layouteer . generateRuler ( this . layouteer . columnsCount , this . layouteer . columnSize ) . split ( ' ' ) . join ( '&nbsp;' ) ; this . element . appendChild ( ruler ) ; for ( let i = 0 ; i < this . index . length ; i ++ ) { const idxRow = this . index [ i ] ; const row = document . createElement ( 'div' ) ; this . element . appendChild ( row ) ; for ( let j = 0 ; j < idxRow . length ; j ++ ) { const ch = this . layouteer . content [ i * idxRow . length + i + j ] ; const cell = document . createElement ( 'span' ) ; cell . innerHTML = ch != ' ' ? ch : '&nbsp;' ; row . appendChild ( cell ) ; const leftIdxItem = j > 0 ? this . index [ i ] [ j - 1 ] : undefined ; const topIdxItem = i > 0 ? this . index [ i - 1 ] [ j ] : undefined ; const currentIdxItem = this . index [ i ] [ j ] = new LayouteerEditorCell ( { el : cell , rowEl : row , row : i , column : j , left : leftIdxItem , top : topIdxItem , right : undefined , bottom : undefined , line : undefined } ) ; cell . _index = currentIdxItem ; if ( leftIdxItem ) { leftIdxItem . right = currentIdxItem ; } if ( topIdxItem ) { topIdxItem . bottom = currentIdxItem ; } } } this . __buildLineIndex__ ( ) ; this . setCursor ( this . index [ 0 ] [ 0 ] ) ; }
Bind editor to given HTML element, create content and bind handlers
Bind editor to given HTML element create content and bind handlers
// event handlers // draw ruler // draw centent // set cursor