UNPKG

on-codemerge

Version:

A WYSIWYG editor for on-codemerge is a user-friendly interface that allows users to edit and view their code in real time, exactly as it will appear in the final product

3 lines (2 loc) 1.65 kB
/*! on-codemerge v1.3.1 @author Pavel Kuzmin @license MIT @homepage https://s00d.github.io/on-codemerge/ @repository git+https://github.com/s00d/on-codemerge.git Copyright (c) 2026 Pavel Kuzmin - Built on 2026-07-02T13:39:17.947Z */ "use strict";var m=Object.defineProperty;var p=(l,e,t)=>e in l?m(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t;var c=(l,e,t)=>p(l,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class x{constructor(e,t,n="horizontal"){c(this,"cell");c(this,"direction");this.cell=t,this.direction=n}execute(){this.direction==="horizontal"?this.mergeRight():this.mergeDown()}mergeRight(){const e=this.cell.parentElement;if(!e)return;const t=Array.from(e.querySelectorAll(".table-cell, .table-header-cell")),n=t.indexOf(this.cell),r=t[n+1];if(!r)return;this.cell.textContent=(this.cell.textContent||"")+" "+(r.textContent||"");const a=parseInt(this.cell.dataset.colspan||"1",10),s=parseInt(r.dataset.colspan||"1",10);this.cell.dataset.colspan=String(a+s),r.remove()}mergeDown(){const e=this.cell.parentElement,t=e.parentElement;if(!e||!t)return;const n=Array.from(t.querySelectorAll(".table-row, .table-header-row")),r=n.indexOf(e),s=Array.from(e.querySelectorAll(".table-cell, .table-header-cell")).indexOf(this.cell),i=n[r+1];if(!i)return;const o=Array.from(i.querySelectorAll(".table-cell, .table-header-cell"))[s];if(!o)return;this.cell.textContent=(this.cell.textContent||"")+" "+(o.textContent||"");const h=parseInt(this.cell.dataset.rowspan||"1",10),d=parseInt(o.dataset.rowspan||"1",10);this.cell.dataset.rowspan=String(h+d),o.remove()}}exports.MergeCellsCommand=x;