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.63 kB
JavaScript
/*! 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 */
;var p=Object.defineProperty;var m=(n,e,t)=>e in n?p(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var i=(n,e,t)=>m(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class u{constructor(e,t,l="horizontal"){i(this,"cell");i(this,"direction");this.cell=t,this.direction=l}execute(){this.direction==="horizontal"?this.splitRight():this.splitDown()}splitRight(){const e=this.cell.parentElement;if(!e)return;const t=parseInt(this.cell.dataset.colspan||"1",10);if(!(t<=1)){this.cell.dataset.colspan="1";for(let l=1;l<t;l++){const s=document.createElement("div");s.className=this.cell.className,s.contentEditable="true",s.textContent="",e.insertBefore(s,this.cell.nextSibling)}}}splitDown(){const e=this.cell.parentElement,t=e.parentElement;if(!e||!t)return;const l=Array.from(t.querySelectorAll(".table-row, .table-header-row")),s=l.indexOf(e),a=Array.from(e.querySelectorAll(".table-cell, .table-header-cell")).indexOf(this.cell),d=parseInt(this.cell.dataset.rowspan||"1",10);if(!(d<=1)){this.cell.dataset.rowspan="1";for(let c=1;c<d;c++){const r=l[s+c];if(!r)continue;const o=document.createElement("div");o.className=this.cell.className,o.contentEditable="true",o.textContent="";const h=r.querySelectorAll(".table-cell, .table-header-cell");h.length>a?r.insertBefore(o,h[a]):r.appendChild(o)}}}}exports.SplitCellCommand=u;