socialcalc-ai 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/core/core.js +28 -8
- package/core/spreadsheet-control.js +5 -0
- package/core/table-editor.js +23 -226
- package/modules/init.js +3 -1
- package/modules/listeners.js +49 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -530,6 +530,17 @@ import {
|
|
|
530
530
|
|
|
531
531
|
---
|
|
532
532
|
|
|
533
|
+
## 📦 Release Notes
|
|
534
|
+
|
|
535
|
+
### v1.0.2
|
|
536
|
+
- **Cell Edit Modal Fix**: Fixed cell click interceptor and mouse delegates so clicking any cell reliably triggers the `CellEditModal` bottom sheet.
|
|
537
|
+
- **Scroll Distortion Fix**: Resolved table border collapse and column misalignment when scrolling past multi-row (`rowspan`) and multi-column (`colspan`) blocks.
|
|
538
|
+
- **Formula Support**: Enhanced modal editing to support formula values (`=SUM(...)`) seamlessly alongside raw numbers, text, and HTML formatting.
|
|
539
|
+
- **Strict Column Sizing**: Enforced CSS pixel widths and `box-sizing: border-box` containment across `<colgroup>` and sizing rows to preserve layout integrity.
|
|
540
|
+
- **Safety Guards**: Added null guards and try/catch protection across SocialCalc workbook control callbacks.
|
|
541
|
+
|
|
542
|
+
---
|
|
543
|
+
|
|
533
544
|
## 📜 License & Acknowledgments
|
|
534
545
|
|
|
535
546
|
- **Original SocialCalc Engine**: Created by Dan Bricklin (co-creator of VisiCalc) and Socialtext.
|
package/core/core.js
CHANGED
|
@@ -5186,6 +5186,7 @@
|
|
|
5186
5186
|
if (context.showRCHeaders) {
|
|
5187
5187
|
newcol = document.createElement("col");
|
|
5188
5188
|
newcol.width = context.rownamewidth;
|
|
5189
|
+
newcol.style.width = context.rownamewidth + "px";
|
|
5189
5190
|
result.appendChild(newcol);
|
|
5190
5191
|
}
|
|
5191
5192
|
|
|
@@ -5197,12 +5198,16 @@
|
|
|
5197
5198
|
) {
|
|
5198
5199
|
newcol = document.createElement("col");
|
|
5199
5200
|
t = context.colwidth[colnum];
|
|
5200
|
-
if (t)
|
|
5201
|
+
if (t) {
|
|
5202
|
+
newcol.width = t;
|
|
5203
|
+
newcol.style.width = t + "px";
|
|
5204
|
+
}
|
|
5201
5205
|
result.appendChild(newcol);
|
|
5202
5206
|
}
|
|
5203
5207
|
if (colpane < context.colpanes.length - 1) {
|
|
5204
5208
|
newcol = document.createElement("col");
|
|
5205
5209
|
newcol.width = context.defaultpanedividerwidth;
|
|
5210
|
+
newcol.style.width = context.defaultpanedividerwidth + "px";
|
|
5206
5211
|
result.appendChild(newcol);
|
|
5207
5212
|
}
|
|
5208
5213
|
}
|
|
@@ -5218,6 +5223,8 @@
|
|
|
5218
5223
|
if (context.showRCHeaders) {
|
|
5219
5224
|
newcell = document.createElement("td");
|
|
5220
5225
|
newcell.style.width = context.rownamewidth + "px";
|
|
5226
|
+
newcell.style.minWidth = context.rownamewidth + "px";
|
|
5227
|
+
newcell.style.maxWidth = context.rownamewidth + "px";
|
|
5221
5228
|
newcell.height = "1";
|
|
5222
5229
|
result.appendChild(newcell);
|
|
5223
5230
|
}
|
|
@@ -5230,13 +5237,21 @@
|
|
|
5230
5237
|
) {
|
|
5231
5238
|
newcell = document.createElement("td");
|
|
5232
5239
|
t = context.colwidth[colnum];
|
|
5233
|
-
if (t)
|
|
5240
|
+
if (t) {
|
|
5241
|
+
newcell.width = t;
|
|
5242
|
+
newcell.style.width = t + "px";
|
|
5243
|
+
newcell.style.minWidth = t + "px";
|
|
5244
|
+
newcell.style.maxWidth = t + "px";
|
|
5245
|
+
}
|
|
5234
5246
|
newcell.height = "1";
|
|
5235
5247
|
result.appendChild(newcell);
|
|
5236
5248
|
}
|
|
5237
5249
|
if (colpane < context.colpanes.length - 1) {
|
|
5238
5250
|
newcell = document.createElement("td");
|
|
5239
5251
|
newcell.width = context.defaultpanedividerwidth;
|
|
5252
|
+
newcell.style.width = context.defaultpanedividerwidth + "px";
|
|
5253
|
+
newcell.style.minWidth = context.defaultpanedividerwidth + "px";
|
|
5254
|
+
newcell.style.maxWidth = context.defaultpanedividerwidth + "px";
|
|
5240
5255
|
newcell.height = "1";
|
|
5241
5256
|
result.appendChild(newcell);
|
|
5242
5257
|
}
|
|
@@ -5289,8 +5304,8 @@
|
|
|
5289
5304
|
if (rownum === firstVisibleRow && colnum === firstVisibleCol) {
|
|
5290
5305
|
// This is the visible start of the scrolled spanned cell in this pane!
|
|
5291
5306
|
isSpanContinuation = true;
|
|
5292
|
-
spanColSpan = Math.min(spanEndCol, panecollimits ? panecollimits.last : spanEndCol) - firstVisibleCol + 1;
|
|
5293
|
-
spanRowSpan = Math.min(spanEndRow, panerowlimits ? panerowlimits.last : spanEndRow) - firstVisibleRow + 1;
|
|
5307
|
+
spanColSpan = Math.max(1, Math.min(spanEndCol, panecollimits ? panecollimits.last : spanEndCol) - firstVisibleCol + 1);
|
|
5308
|
+
spanRowSpan = Math.max(1, Math.min(spanEndRow, panerowlimits ? panerowlimits.last : spanEndRow) - firstVisibleRow + 1);
|
|
5294
5309
|
cell = originCell;
|
|
5295
5310
|
} else {
|
|
5296
5311
|
// Covered by the visible span in this pane -- skip
|
|
@@ -5416,6 +5431,9 @@
|
|
|
5416
5431
|
} else stylestr += "text-align:left;";
|
|
5417
5432
|
}
|
|
5418
5433
|
|
|
5434
|
+
var activeColSpan = isSpanContinuation ? spanColSpan : (result.colSpan || cell.colspan || 1);
|
|
5435
|
+
var activeRowSpan = isSpanContinuation ? spanRowSpan : (result.rowSpan || cell.rowspan || 1);
|
|
5436
|
+
|
|
5419
5437
|
num = cell.bt;
|
|
5420
5438
|
if (num && (!isSpanContinuation || (originCR && rownum === originCR.row))) {
|
|
5421
5439
|
stylestr += "border-top:" + sheetobj.borderstyles[num] + ";";
|
|
@@ -5428,12 +5446,12 @@
|
|
|
5428
5446
|
if (
|
|
5429
5447
|
context.CellInPane(
|
|
5430
5448
|
rownum,
|
|
5431
|
-
colnum +
|
|
5449
|
+
colnum + activeColSpan,
|
|
5432
5450
|
rowpane,
|
|
5433
5451
|
colpane
|
|
5434
5452
|
)
|
|
5435
5453
|
)
|
|
5436
|
-
t = SocialCalc.crToCoord(colnum +
|
|
5454
|
+
t = SocialCalc.crToCoord(colnum + activeColSpan, rownum);
|
|
5437
5455
|
else t = "nomatch";
|
|
5438
5456
|
if (context.cellskip[t]) t = context.cellskip[t];
|
|
5439
5457
|
if (!sheetobj.cells[t] || !sheetobj.cells[t].bl)
|
|
@@ -5446,13 +5464,13 @@
|
|
|
5446
5464
|
} else if (context.showGrid) {
|
|
5447
5465
|
if (
|
|
5448
5466
|
context.CellInPane(
|
|
5449
|
-
rownum +
|
|
5467
|
+
rownum + activeRowSpan,
|
|
5450
5468
|
colnum,
|
|
5451
5469
|
rowpane,
|
|
5452
5470
|
colpane
|
|
5453
5471
|
)
|
|
5454
5472
|
)
|
|
5455
|
-
t = SocialCalc.crToCoord(colnum, rownum +
|
|
5473
|
+
t = SocialCalc.crToCoord(colnum, rownum + activeRowSpan);
|
|
5456
5474
|
else t = "nomatch";
|
|
5457
5475
|
if (context.cellskip[t]) t = context.cellskip[t];
|
|
5458
5476
|
if (!sheetobj.cells[t] || !sheetobj.cells[t].bt)
|
|
@@ -5483,6 +5501,8 @@
|
|
|
5483
5501
|
}
|
|
5484
5502
|
|
|
5485
5503
|
result.style.cssText = stylestr;
|
|
5504
|
+
result.style.boxSizing = "border-box";
|
|
5505
|
+
result.style.overflow = "hidden";
|
|
5486
5506
|
|
|
5487
5507
|
//!!!!!!!!!
|
|
5488
5508
|
// NOTE: csss and cssc are not supported yet.
|
|
@@ -7014,8 +7014,13 @@ SocialCalc.SpreadsheetCmdTable = {
|
|
|
7014
7014
|
// this is for checkmark toggling
|
|
7015
7015
|
SocialCalc.Callbacks.ToggleCell = function (cellname) {
|
|
7016
7016
|
var control = SocialCalc.GetCurrentWorkBookControl();
|
|
7017
|
+
if (!control || !control.currentSheetButton || !control.workbook || !control.workbook.sheetArr) {
|
|
7018
|
+
return;
|
|
7019
|
+
}
|
|
7017
7020
|
var sheetid = control.currentSheetButton.id;
|
|
7021
|
+
if (!control.workbook.sheetArr[sheetid]) return;
|
|
7018
7022
|
var sheetobj = control.workbook.sheetArr[sheetid].sheet;
|
|
7023
|
+
if (!sheetobj || !sheetobj.cells) return;
|
|
7019
7024
|
var cell = sheetobj.cells[cellname];
|
|
7020
7025
|
var sheetname = sheetobj.sheetname;
|
|
7021
7026
|
|
package/core/table-editor.js
CHANGED
|
@@ -1582,22 +1582,33 @@
|
|
|
1582
1582
|
mouseinfo.registeredElements.push({ element: element, editor: editor });
|
|
1583
1583
|
}
|
|
1584
1584
|
|
|
1585
|
+
if (!SocialCalc.ProcessEditorMouseDownHandler) {
|
|
1586
|
+
SocialCalc.ProcessEditorMouseDownHandler = function (e) {
|
|
1587
|
+
return SocialCalc.ProcessEditorMouseDown(e);
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
if (!SocialCalc.ProcessEditorDblClickHandler) {
|
|
1591
|
+
SocialCalc.ProcessEditorDblClickHandler = function (e) {
|
|
1592
|
+
return SocialCalc.ProcessEditorDblClick(e);
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1585
1596
|
if (element.addEventListener) {
|
|
1586
1597
|
// DOM Level 2 -- Firefox, et al
|
|
1587
1598
|
element.addEventListener(
|
|
1588
1599
|
"mousedown",
|
|
1589
|
-
SocialCalc.
|
|
1600
|
+
SocialCalc.ProcessEditorMouseDownHandler,
|
|
1590
1601
|
false
|
|
1591
1602
|
);
|
|
1592
1603
|
element.addEventListener(
|
|
1593
1604
|
"dblclick",
|
|
1594
|
-
SocialCalc.
|
|
1605
|
+
SocialCalc.ProcessEditorDblClickHandler,
|
|
1595
1606
|
false
|
|
1596
1607
|
);
|
|
1597
1608
|
} else if (element.attachEvent) {
|
|
1598
1609
|
// IE 5+
|
|
1599
|
-
element.attachEvent("onmousedown", SocialCalc.
|
|
1600
|
-
element.attachEvent("ondblclick", SocialCalc.
|
|
1610
|
+
element.attachEvent("onmousedown", SocialCalc.ProcessEditorMouseDownHandler);
|
|
1611
|
+
element.attachEvent("ondblclick", SocialCalc.ProcessEditorDblClickHandler);
|
|
1601
1612
|
} else {
|
|
1602
1613
|
// don't handle this
|
|
1603
1614
|
throw "Browser not supported";
|
|
@@ -1629,21 +1640,21 @@
|
|
|
1629
1640
|
// DOM Level 2
|
|
1630
1641
|
oldelement.removeEventListener(
|
|
1631
1642
|
"mousedown",
|
|
1632
|
-
SocialCalc.ProcessEditorMouseDown,
|
|
1643
|
+
SocialCalc.ProcessEditorMouseDownHandler || SocialCalc.ProcessEditorMouseDown,
|
|
1633
1644
|
false
|
|
1634
1645
|
);
|
|
1635
1646
|
oldelement.removeEventListener(
|
|
1636
1647
|
"dblclick",
|
|
1637
|
-
SocialCalc.ProcessEditorDblClick,
|
|
1648
|
+
SocialCalc.ProcessEditorDblClickHandler || SocialCalc.ProcessEditorDblClick,
|
|
1638
1649
|
false
|
|
1639
1650
|
);
|
|
1640
1651
|
} else if (oldelement.detachEvent) {
|
|
1641
1652
|
// IE
|
|
1642
1653
|
oldelement.detachEvent(
|
|
1643
1654
|
"onmousedown",
|
|
1644
|
-
SocialCalc.ProcessEditorMouseDown
|
|
1655
|
+
SocialCalc.ProcessEditorMouseDownHandler || SocialCalc.ProcessEditorMouseDown
|
|
1645
1656
|
);
|
|
1646
|
-
oldelement.detachEvent("ondblclick", SocialCalc.ProcessEditorDblClick);
|
|
1657
|
+
oldelement.detachEvent("ondblclick", SocialCalc.ProcessEditorDblClickHandler || SocialCalc.ProcessEditorDblClick);
|
|
1647
1658
|
}
|
|
1648
1659
|
mouseinfo.registeredElements.splice(i, 1);
|
|
1649
1660
|
}
|
|
@@ -3772,18 +3783,6 @@
|
|
|
3772
3783
|
return;
|
|
3773
3784
|
}
|
|
3774
3785
|
|
|
3775
|
-
if ((vamount == 1 || vamount == -1) && hamount == 0) {
|
|
3776
|
-
// special case quick scrolls
|
|
3777
|
-
if (vamount == 1) {
|
|
3778
|
-
editor.ScrollTableUpOneRow();
|
|
3779
|
-
} else {
|
|
3780
|
-
editor.ScrollTableDownOneRow();
|
|
3781
|
-
}
|
|
3782
|
-
if (editor.ecell) editor.SetECellHeaders("selected");
|
|
3783
|
-
editor.SchedulePositionCalculations();
|
|
3784
|
-
return;
|
|
3785
|
-
}
|
|
3786
|
-
|
|
3787
3786
|
// Do a gross move and render
|
|
3788
3787
|
|
|
3789
3788
|
if (vamount != 0 || hamount != 0) {
|
|
@@ -3874,215 +3873,13 @@
|
|
|
3874
3873
|
};
|
|
3875
3874
|
|
|
3876
3875
|
SocialCalc.ScrollTableUpOneRow = function (editor) {
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
rownum,
|
|
3880
|
-
colnum,
|
|
3881
|
-
colpane,
|
|
3882
|
-
cell,
|
|
3883
|
-
oldrownum,
|
|
3884
|
-
maxspan,
|
|
3885
|
-
newbottomrow,
|
|
3886
|
-
newrow,
|
|
3887
|
-
oldchild,
|
|
3888
|
-
bottomrownum;
|
|
3889
|
-
var rowneedsrefresh = {};
|
|
3890
|
-
|
|
3891
|
-
var context = editor.context;
|
|
3892
|
-
var sheetobj = context.sheetobj;
|
|
3893
|
-
var tableobj = editor.fullgrid;
|
|
3894
|
-
|
|
3895
|
-
var tbodyobj;
|
|
3896
|
-
|
|
3897
|
-
tbodyobj = tableobj.lastChild;
|
|
3898
|
-
|
|
3899
|
-
toprow = context.showRCHeaders ? 2 : 1;
|
|
3900
|
-
for (rowpane = 0; rowpane < context.rowpanes.length - 1; rowpane++) {
|
|
3901
|
-
toprow +=
|
|
3902
|
-
context.rowpanes[rowpane].last - context.rowpanes[rowpane].first + 2; // skip pane and spacing row
|
|
3903
|
-
}
|
|
3904
|
-
|
|
3905
|
-
tbodyobj.removeChild(tbodyobj.childNodes[toprow]);
|
|
3906
|
-
|
|
3907
|
-
context.rowpanes[rowpane].first++;
|
|
3908
|
-
context.rowpanes[rowpane].last++;
|
|
3909
|
-
editor.FitToEditTable();
|
|
3910
|
-
context.CalculateColWidthData(); // Just in case, since normally done in RenderSheet
|
|
3911
|
-
|
|
3912
|
-
newbottomrow = context.RenderRow(context.rowpanes[rowpane].last, rowpane);
|
|
3913
|
-
tbodyobj.appendChild(newbottomrow);
|
|
3914
|
-
|
|
3915
|
-
// if scrolled off a row with starting rowspans, replace rows for the largest rowspan
|
|
3916
|
-
|
|
3917
|
-
var maxrowspan = 1;
|
|
3918
|
-
oldrownum = context.rowpanes[rowpane].first - 1;
|
|
3919
|
-
|
|
3920
|
-
for (colpane = 0; colpane < context.colpanes.length; colpane++) {
|
|
3921
|
-
for (
|
|
3922
|
-
colnum = context.colpanes[colpane].first;
|
|
3923
|
-
colnum <= context.colpanes[colpane].last;
|
|
3924
|
-
colnum++
|
|
3925
|
-
) {
|
|
3926
|
-
var coord = SocialCalc.crToCoord(colnum, oldrownum);
|
|
3927
|
-
if (context.cellskip[coord]) continue;
|
|
3928
|
-
cell = sheetobj.cells[coord];
|
|
3929
|
-
if (cell && cell.rowspan > maxrowspan) maxrowspan = cell.rowspan;
|
|
3930
|
-
}
|
|
3931
|
-
}
|
|
3932
|
-
|
|
3933
|
-
if (maxrowspan > 1) {
|
|
3934
|
-
for (rownum = 1; rownum < maxrowspan; rownum++) {
|
|
3935
|
-
if (rownum + oldrownum >= context.rowpanes[rowpane].last) break;
|
|
3936
|
-
newrow = context.RenderRow(rownum + oldrownum, rowpane);
|
|
3937
|
-
oldchild = tbodyobj.childNodes[toprow + rownum - 1];
|
|
3938
|
-
tbodyobj.replaceChild(newrow, oldchild);
|
|
3939
|
-
}
|
|
3940
|
-
}
|
|
3941
|
-
|
|
3942
|
-
// if added a row that includes rowspans from above, update the size of those to include new row
|
|
3943
|
-
|
|
3944
|
-
bottomrownum = context.rowpanes[rowpane].last;
|
|
3945
|
-
|
|
3946
|
-
for (colpane = 0; colpane < context.colpanes.length; colpane++) {
|
|
3947
|
-
for (
|
|
3948
|
-
colnum = context.colpanes[colpane].first;
|
|
3949
|
-
colnum <= context.colpanes[colpane].last;
|
|
3950
|
-
colnum++
|
|
3951
|
-
) {
|
|
3952
|
-
coord = context.cellskip[SocialCalc.crToCoord(colnum, bottomrownum)];
|
|
3953
|
-
if (!coord) continue; // only look at spanned cells
|
|
3954
|
-
rownum = context.coordToCR[coord].row - 0;
|
|
3955
|
-
if (
|
|
3956
|
-
rownum == context.rowpanes[rowpane].last ||
|
|
3957
|
-
rownum < context.rowpanes[rowpane].first
|
|
3958
|
-
)
|
|
3959
|
-
continue; // this row (colspan) or starts above pane
|
|
3960
|
-
cell = sheetobj.cells[coord];
|
|
3961
|
-
if (cell && cell.rowspan > 1) rowneedsrefresh[rownum] = true; // remember row num to update
|
|
3962
|
-
}
|
|
3963
|
-
}
|
|
3964
|
-
|
|
3965
|
-
for (rownum in rowneedsrefresh) {
|
|
3966
|
-
newrow = context.RenderRow(rownum, rowpane);
|
|
3967
|
-
oldchild =
|
|
3968
|
-
tbodyobj.childNodes[
|
|
3969
|
-
toprow + (rownum - context.rowpanes[rowpane].first)
|
|
3970
|
-
];
|
|
3971
|
-
tbodyobj.replaceChild(newrow, oldchild);
|
|
3972
|
-
}
|
|
3973
|
-
|
|
3974
|
-
return tableobj;
|
|
3876
|
+
SocialCalc.ScrollRelativeBoth(editor, 1, 0);
|
|
3877
|
+
return editor.fullgrid;
|
|
3975
3878
|
};
|
|
3976
3879
|
|
|
3977
3880
|
SocialCalc.ScrollTableDownOneRow = function (editor) {
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
rownum,
|
|
3981
|
-
colnum,
|
|
3982
|
-
colpane,
|
|
3983
|
-
cell,
|
|
3984
|
-
newrownum,
|
|
3985
|
-
maxspan,
|
|
3986
|
-
newbottomrow,
|
|
3987
|
-
newrow,
|
|
3988
|
-
oldchild,
|
|
3989
|
-
bottomrownum,
|
|
3990
|
-
maxrowspan,
|
|
3991
|
-
coord;
|
|
3992
|
-
var rowneedsrefresh = {};
|
|
3993
|
-
|
|
3994
|
-
var context = editor.context;
|
|
3995
|
-
var sheetobj = context.sheetobj;
|
|
3996
|
-
var tableobj = editor.fullgrid;
|
|
3997
|
-
|
|
3998
|
-
var tbodyobj;
|
|
3999
|
-
|
|
4000
|
-
tbodyobj = tableobj.lastChild;
|
|
4001
|
-
|
|
4002
|
-
toprow = context.showRCHeaders ? 2 : 1;
|
|
4003
|
-
for (rowpane = 0; rowpane < context.rowpanes.length - 1; rowpane++) {
|
|
4004
|
-
toprow +=
|
|
4005
|
-
context.rowpanes[rowpane].last - context.rowpanes[rowpane].first + 2; // skip pane and spacing row
|
|
4006
|
-
}
|
|
4007
|
-
|
|
4008
|
-
tbodyobj.removeChild(
|
|
4009
|
-
tbodyobj.childNodes[
|
|
4010
|
-
toprow +
|
|
4011
|
-
(context.rowpanes[rowpane].last - context.rowpanes[rowpane].first)
|
|
4012
|
-
]
|
|
4013
|
-
);
|
|
4014
|
-
|
|
4015
|
-
context.rowpanes[rowpane].first--;
|
|
4016
|
-
context.rowpanes[rowpane].last--;
|
|
4017
|
-
editor.FitToEditTable();
|
|
4018
|
-
context.CalculateColWidthData(); // Just in case, since normally done in RenderSheet
|
|
4019
|
-
|
|
4020
|
-
newrow = context.RenderRow(context.rowpanes[rowpane].first, rowpane);
|
|
4021
|
-
tbodyobj.insertBefore(newrow, tbodyobj.childNodes[toprow]);
|
|
4022
|
-
|
|
4023
|
-
// if inserted a row with starting rowspans, replace rows for the largest rowspan
|
|
4024
|
-
|
|
4025
|
-
maxrowspan = 1;
|
|
4026
|
-
newrownum = context.rowpanes[rowpane].first;
|
|
4027
|
-
|
|
4028
|
-
for (colpane = 0; colpane < context.colpanes.length; colpane++) {
|
|
4029
|
-
for (
|
|
4030
|
-
colnum = context.colpanes[colpane].first;
|
|
4031
|
-
colnum <= context.colpanes[colpane].last;
|
|
4032
|
-
colnum++
|
|
4033
|
-
) {
|
|
4034
|
-
coord = SocialCalc.crToCoord(colnum, newrownum);
|
|
4035
|
-
if (context.cellskip[coord]) continue;
|
|
4036
|
-
cell = sheetobj.cells[coord];
|
|
4037
|
-
if (cell && cell.rowspan > maxrowspan) maxrowspan = cell.rowspan;
|
|
4038
|
-
}
|
|
4039
|
-
}
|
|
4040
|
-
|
|
4041
|
-
if (maxrowspan > 1) {
|
|
4042
|
-
for (rownum = 1; rownum < maxrowspan; rownum++) {
|
|
4043
|
-
if (rownum + newrownum > context.rowpanes[rowpane].last) break;
|
|
4044
|
-
newrow = context.RenderRow(rownum + newrownum, rowpane);
|
|
4045
|
-
oldchild = tbodyobj.childNodes[toprow + rownum];
|
|
4046
|
-
tbodyobj.replaceChild(newrow, oldchild);
|
|
4047
|
-
}
|
|
4048
|
-
}
|
|
4049
|
-
|
|
4050
|
-
// if last row now includes rowspans or rowspans from above, update the size of those to remove deleted row
|
|
4051
|
-
|
|
4052
|
-
bottomrownum = context.rowpanes[rowpane].last;
|
|
4053
|
-
|
|
4054
|
-
for (colpane = 0; colpane < context.colpanes.length; colpane++) {
|
|
4055
|
-
for (
|
|
4056
|
-
colnum = context.colpanes[colpane].first;
|
|
4057
|
-
colnum <= context.colpanes[colpane].last;
|
|
4058
|
-
colnum++
|
|
4059
|
-
) {
|
|
4060
|
-
coord = SocialCalc.crToCoord(colnum, bottomrownum);
|
|
4061
|
-
cell = sheetobj.cells[coord];
|
|
4062
|
-
if (cell && cell.rowspan > 1) {
|
|
4063
|
-
rowneedsrefresh[bottomrownum] = true; // need to update this row
|
|
4064
|
-
continue;
|
|
4065
|
-
}
|
|
4066
|
-
coord = context.cellskip[SocialCalc.crToCoord(colnum, bottomrownum)];
|
|
4067
|
-
if (!coord) continue; // only look at spanned cells
|
|
4068
|
-
rownum = context.coordToCR[coord].row - 0;
|
|
4069
|
-
if (rownum == bottomrownum || rownum < context.rowpanes[rowpane].first)
|
|
4070
|
-
continue; // this row (colspan) or starts above pane
|
|
4071
|
-
cell = sheetobj.cells[coord];
|
|
4072
|
-
if (cell && cell.rowspan > 1) rowneedsrefresh[rownum] = true; // remember row num to update
|
|
4073
|
-
}
|
|
4074
|
-
}
|
|
4075
|
-
|
|
4076
|
-
for (rownum in rowneedsrefresh) {
|
|
4077
|
-
newrow = context.RenderRow(rownum, rowpane);
|
|
4078
|
-
oldchild =
|
|
4079
|
-
tbodyobj.childNodes[
|
|
4080
|
-
toprow + (rownum - context.rowpanes[rowpane].first)
|
|
4081
|
-
];
|
|
4082
|
-
tbodyobj.replaceChild(newrow, oldchild);
|
|
4083
|
-
}
|
|
4084
|
-
|
|
4085
|
-
return tableobj;
|
|
3881
|
+
SocialCalc.ScrollRelativeBoth(editor, -1, 0);
|
|
3882
|
+
return editor.fullgrid;
|
|
4086
3883
|
};
|
|
4087
3884
|
|
|
4088
3885
|
// *************************************
|
package/modules/init.js
CHANGED
|
@@ -8,9 +8,10 @@ if (typeof window !== "undefined" && window.SocialCalc) {
|
|
|
8
8
|
SocialCalc = global.SocialCalc;
|
|
9
9
|
} else {
|
|
10
10
|
console.error("SocialCalc not found in global scope");
|
|
11
|
-
SocialCalc = {}; // Fallback to prevent errors
|
|
12
11
|
}
|
|
13
12
|
|
|
13
|
+
import { setupMouseListener } from "./listeners.js";
|
|
14
|
+
|
|
14
15
|
export function initializeApp(data) {
|
|
15
16
|
/* Initializes the spreadsheet */
|
|
16
17
|
// Try multiple candidate IDs so the renderer can namespace its elements
|
|
@@ -91,4 +92,5 @@ export function initializeApp(data) {
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
spreadsheet.DoOnResize();
|
|
95
|
+
setupMouseListener();
|
|
94
96
|
}
|
package/modules/listeners.js
CHANGED
|
@@ -30,6 +30,7 @@ export function enableCellEditModal() {
|
|
|
30
30
|
if (typeof window !== "undefined" && window.SocialCalc) {
|
|
31
31
|
window.SocialCalc.isCellEditModalEnabled = () => true;
|
|
32
32
|
}
|
|
33
|
+
setupMouseListener();
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
/**
|
|
@@ -57,6 +58,9 @@ export function toggleCellEditModal(show) {
|
|
|
57
58
|
if (typeof window !== "undefined" && window.SocialCalc) {
|
|
58
59
|
window.SocialCalc.isCellEditModalEnabled = () => _cellEditModalEnabled;
|
|
59
60
|
}
|
|
61
|
+
if (_cellEditModalEnabled) {
|
|
62
|
+
setupMouseListener();
|
|
63
|
+
}
|
|
60
64
|
return _cellEditModalEnabled;
|
|
61
65
|
}
|
|
62
66
|
|
|
@@ -167,7 +171,15 @@ export function setupMouseListener() {
|
|
|
167
171
|
if (typeof window !== "undefined" && window.SocialCalc) {
|
|
168
172
|
SocialCalc = window.SocialCalc;
|
|
169
173
|
}
|
|
170
|
-
if (!SocialCalc || !SocialCalc.EditorMouseInfo)
|
|
174
|
+
if (!SocialCalc || !SocialCalc.EditorMouseInfo) {
|
|
175
|
+
if (typeof window !== "undefined") {
|
|
176
|
+
setTimeout(setupMouseListener, 50);
|
|
177
|
+
}
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (SocialCalc._customMouseListenerInstalled) return;
|
|
182
|
+
SocialCalc._customMouseListenerInstalled = true;
|
|
171
183
|
|
|
172
184
|
const originalDblClick = SocialCalc.ProcessEditorDblClick;
|
|
173
185
|
|
|
@@ -292,7 +304,11 @@ export function setupMouseListener() {
|
|
|
292
304
|
|
|
293
305
|
// Toggle Cell Callback
|
|
294
306
|
if (SocialCalc.Callbacks && SocialCalc.Callbacks.ToggleCell) {
|
|
295
|
-
|
|
307
|
+
try {
|
|
308
|
+
SocialCalc.Callbacks.ToggleCell(result.coord);
|
|
309
|
+
} catch (err) {
|
|
310
|
+
// Ignore toggle cell errors in custom environments
|
|
311
|
+
}
|
|
296
312
|
}
|
|
297
313
|
|
|
298
314
|
// Move ECell (Updates Selection)
|
|
@@ -367,7 +383,7 @@ export function setupMouseListener() {
|
|
|
367
383
|
const originalKeyPress = SocialCalc.ProcessKeyPress;
|
|
368
384
|
|
|
369
385
|
SocialCalc.ProcessKeyDown = function (e) {
|
|
370
|
-
const isModalOpen = !!document.querySelector(".sc-cell-edit-backdrop");
|
|
386
|
+
const isModalOpen = !!document.querySelector(".sc-cell-modal-backdrop, .sc-cell-edit-backdrop, .sc-modal-container");
|
|
371
387
|
const activeElement = document.activeElement;
|
|
372
388
|
const isTypingInInput =
|
|
373
389
|
activeElement &&
|
|
@@ -386,7 +402,7 @@ export function setupMouseListener() {
|
|
|
386
402
|
};
|
|
387
403
|
|
|
388
404
|
SocialCalc.ProcessKeyPress = function (e) {
|
|
389
|
-
const isModalOpen = !!document.querySelector(".sc-cell-edit-backdrop");
|
|
405
|
+
const isModalOpen = !!document.querySelector(".sc-cell-modal-backdrop, .sc-cell-edit-backdrop, .sc-modal-container");
|
|
390
406
|
const activeElement = document.activeElement;
|
|
391
407
|
const isTypingInInput =
|
|
392
408
|
activeElement &&
|
|
@@ -416,8 +432,8 @@ function triggerCustomModal(editor) {
|
|
|
416
432
|
if (!editor || !editor.ecell) return;
|
|
417
433
|
|
|
418
434
|
const coord = editor.ecell.coord;
|
|
419
|
-
const sheet = editor.context.sheetobj;
|
|
420
|
-
const cell = sheet.GetAssuredCell(coord);
|
|
435
|
+
const sheet = editor.context ? editor.context.sheetobj : null;
|
|
436
|
+
const cell = sheet && sheet.GetAssuredCell ? sheet.GetAssuredCell(coord) : null;
|
|
421
437
|
|
|
422
438
|
// Hide the native input box and cancel its timer
|
|
423
439
|
if (editor.inputBox) {
|
|
@@ -442,25 +458,35 @@ function triggerCustomModal(editor) {
|
|
|
442
458
|
|
|
443
459
|
// Determine initial text
|
|
444
460
|
let initialText = "";
|
|
445
|
-
if (cell
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
461
|
+
if (cell) {
|
|
462
|
+
if (cell.formula) {
|
|
463
|
+
initialText = "=" + cell.formula;
|
|
464
|
+
} else if (cell.datavalue !== undefined && cell.datavalue !== null) {
|
|
465
|
+
initialText = String(cell.datavalue);
|
|
466
|
+
} else if (cell.displaystring !== undefined && cell.displaystring !== null) {
|
|
467
|
+
initialText = String(cell.displaystring);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
if (!initialText && SocialCalc && SocialCalc.GetCellContents && sheet) {
|
|
471
|
+
initialText = SocialCalc.GetCellContents(sheet, coord) || "";
|
|
449
472
|
}
|
|
450
473
|
|
|
451
474
|
// Callback when user confirms edit in Modal
|
|
452
475
|
const handleOk = (newValue) => {
|
|
453
476
|
let cmd = "";
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
if (isNum) {
|
|
457
|
-
cmd = `set ${coord} value n ${newValue}`;
|
|
477
|
+
if (typeof newValue === "string" && newValue.startsWith("=")) {
|
|
478
|
+
cmd = `set ${coord} formula ${newValue.slice(1)}`;
|
|
458
479
|
} else {
|
|
459
|
-
const
|
|
460
|
-
if (
|
|
461
|
-
cmd = `set ${coord}
|
|
480
|
+
const isNum = !isNaN(Number(newValue)) && newValue.trim() !== "";
|
|
481
|
+
if (isNum) {
|
|
482
|
+
cmd = `set ${coord} value n ${newValue}`;
|
|
462
483
|
} else {
|
|
463
|
-
|
|
484
|
+
const isHtml = /<[a-z][\s\S]*>/i.test(newValue);
|
|
485
|
+
if (isHtml) {
|
|
486
|
+
cmd = `set ${coord} text th ${newValue}\nset ${coord} textvalueformat text-html`;
|
|
487
|
+
} else {
|
|
488
|
+
cmd = `set ${coord} text t ${newValue}`;
|
|
489
|
+
}
|
|
464
490
|
}
|
|
465
491
|
}
|
|
466
492
|
|
|
@@ -529,3 +555,8 @@ export function setupCellChangeListener(callback) {
|
|
|
529
555
|
};
|
|
530
556
|
}
|
|
531
557
|
|
|
558
|
+
// Auto-initialize mouse listener if in browser environment
|
|
559
|
+
if (typeof window !== "undefined") {
|
|
560
|
+
setupMouseListener();
|
|
561
|
+
}
|
|
562
|
+
|
package/package.json
CHANGED