Skip to content

Commit 18887e3

Browse files
committedApr 25, 2024
Improve code to resize tables
Before: resizing div for each cell in column/row Now: one resizing div across entire column/row Fixed problems: - resizing div could be missing here or there - cursor would change during resizing when moving it from column to row and vice versa (should not change) - removed word-break rule
1 parent a089c0a commit 18887e3

14 files changed

+433
-404
lines changed
 

‎public/notes.css

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
:root {
22
--default-sidebar-width: 25%;
3+
--resizing-div-overflow: -10000px;
34
}
45

56
html {
@@ -372,6 +373,7 @@ body.resizing-sidebar-locked-max { cursor: w-resize; }
372373
border: var(--table-border);
373374
border-spacing: 0;
374375
border-collapse: collapse;
376+
overflow: hidden !important;
375377
}
376378

377379
#content table td {
@@ -461,26 +463,33 @@ body.with-control.resizing-img #content {
461463

462464
.table-resizing-div {
463465
position: absolute;
466+
z-index: 100;
464467
}
465468

466-
.table-resizing-div.active {
469+
body:not(.resizing-table) .table-resizing-div:hover, .table-resizing-div.active {
467470
background: var(--resizing-line-color);
468471
}
469472

470473
.table-column-resizing-div {
471-
top: 0;
474+
top: var(--resizing-div-overflow);
475+
bottom: var(--resizing-div-overflow);
472476
right: 0;
473-
bottom: 0;
477+
width: var(--table-resizing-div-thickness);
478+
}
479+
480+
body:not(.resizing-table) .table-column-resizing-div {
474481
cursor: col-resize;
475-
width: 4px;
476482
}
477483

478484
.table-row-resizing-div {
479-
left: 0;
480-
right: 0;
485+
left: var(--resizing-div-overflow);
486+
right: var(--resizing-div-overflow);
481487
bottom: 0;
488+
height: var(--table-resizing-div-thickness);
489+
}
490+
491+
body:not(.resizing-table) .table-row-resizing-div {
482492
cursor: row-resize;
483-
height: 4px;
484493
}
485494

486495
body.resizing-table-column { cursor: col-resize; }

‎public/themes/dark.css

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
--table-border: 3px solid #454545;
8989
--table-td-border: 1px solid #222;
9090
--table-td-heading-background-color: #222;
91+
--table-resizing-div-thickness: 4px;
9192
--resizing-line-color: #0000ff;
9293

9394

‎public/themes/light.css

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
--table-border: 3px solid #171717;
8989
--table-td-border: 1px solid silver;
9090
--table-td-heading-background-color: #dddddd;
91+
--table-resizing-div-thickness: 4px;
9192
--resizing-line-color: #0000ff;
9293

9394

‎src/notes/content/__tests__/table.test.ts

-156
This file was deleted.

‎src/notes/content/init.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import { dispatchNoteEdited } from "notes/events";
2+
13
import { initImgs } from "./img";
24
import { initTables } from "./table";
3-
import renderTableContextMenu from "./render-table-context-menu";
5+
import renderTableContextMenu from "./table/render/render-table-context-menu";
46

57
export default () => {
68
initImgs();
79
initTables({
10+
onResize: dispatchNoteEdited,
811
contextMenuRenderFunction: renderTableContextMenu,
912
});
1013
};

0 commit comments

Comments
 (0)