Skip to content

Commit 88fbb9b

Browse files
committed
feat: 表格增加右侧操作菜单
1 parent 0f54e69 commit 88fbb9b

File tree

10 files changed

+1194
-298
lines changed

10 files changed

+1194
-298
lines changed

app/assets/css/writing-studio/plugins/table.css

Lines changed: 110 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
.writing-editor .tiptap .tableWrapper {
22
box-sizing: border-box;
3+
position: relative;
34
width: calc(100% - 1.5rem);
45
max-width: calc(100% - 1.5rem);
5-
margin: 1.25rem 1.5rem 1.5rem 0;
6+
padding: 1.25rem 1.5rem 1.5rem 0;
67
overflow-x: auto;
78
overflow-y: visible;
89
}
@@ -174,34 +175,56 @@
174175
background-color: transparent;
175176
}
176177

177-
.writing-editor .tiptap[data-ws-column-menu-active="true"] table .selectedCell::after {
178+
.writing-editor .tiptap[data-ws-selection-overlay-active="true"] table .selectedCell {
179+
border-style: solid;
180+
border-color: oklch(var(--border));
181+
background-color: transparent;
182+
}
183+
184+
.writing-editor .tiptap[data-ws-column-menu-active="true"] table .selectedCell::after,
185+
.writing-editor .tiptap[data-ws-selection-overlay-active="true"] table .selectedCell::after {
178186
background: transparent;
179187
}
180188

181189
.ws-table-column-selection {
182190
position: absolute;
183191
pointer-events: none;
192+
z-index: 1;
184193
}
185194

186195
.ws-table-column-selection-outline {
196+
position: relative;
187197
width: 100%;
188198
height: 100%;
189199
border: 2px solid oklch(var(--primary));
200+
border-radius: 0;
190201
}
191202

192-
/* .ws-table-column-selection-outline--column {
193-
border-radius: 0.45rem;
194-
} */
203+
.ws-table-column-selection--overlay .ws-table-column-selection-outline {
204+
border-color: oklch(var(--primary) / 0.72);
205+
border-radius: 0;
206+
background: oklch(var(--primary) / 0.12);
207+
}
208+
209+
.ws-table-column-selection-outline--column {
210+
border-radius: 0;
211+
}
195212

196213
.ws-table-column-handle-anchor {
197214
position: absolute;
198-
z-index: 90;
215+
z-index: 2;
216+
transform: translate(-50%, -50%);
217+
}
218+
219+
.ws-table-selection-handle-anchor {
220+
position: absolute;
221+
z-index: 2;
199222
transform: translate(-50%, -50%);
200223
}
201224

202225
.ws-table-column-bubble-layer {
203226
position: relative;
204-
z-index: 100;
227+
z-index: 3;
205228
}
206229

207230
.ws-table-column-handle {
@@ -257,9 +280,60 @@
257280
transform: scale(1);
258281
}
259282

283+
.ws-table-selection-handle {
284+
width: 6px;
285+
min-width: 6px;
286+
height: 18px;
287+
min-height: 18px;
288+
padding: 0;
289+
border: 2px solid oklch(var(--background));
290+
border-radius: 9999px;
291+
background: oklch(var(--primary));
292+
color: transparent;
293+
box-shadow: none;
294+
overflow: hidden;
295+
transition:
296+
width 0.16s ease,
297+
min-width 0.16s ease,
298+
height 0.16s ease,
299+
min-height 0.16s ease,
300+
border-radius 0.16s ease,
301+
background-color 0.16s ease,
302+
color 0.16s ease,
303+
transform 0.16s ease;
304+
}
305+
306+
.ws-table-selection-handle:hover,
307+
.ws-table-selection-handle:focus-visible,
308+
.ws-table-selection-handle--active {
309+
width: 1.5rem;
310+
min-width: 1.5rem;
311+
height: 2.5rem;
312+
min-height: 2.5rem;
313+
border-radius: 0.4rem;
314+
border-color: oklch(var(--background));
315+
background: oklch(var(--primary));
316+
color: oklch(var(--primary-foreground));
317+
}
318+
319+
.ws-table-selection-handle-icon {
320+
width: 0.95rem;
321+
height: 0.95rem;
322+
opacity: 0;
323+
transform: scale(0.7);
324+
transition: opacity 0.16s ease, transform 0.16s ease;
325+
}
326+
327+
.ws-table-selection-handle:hover .ws-table-selection-handle-icon,
328+
.ws-table-selection-handle:focus-visible .ws-table-selection-handle-icon,
329+
.ws-table-selection-handle--active .ws-table-selection-handle-icon {
330+
opacity: 1;
331+
transform: scale(1);
332+
}
333+
260334
.ws-table-column-menu {
261335
position: relative;
262-
z-index: 110;
336+
z-index: 4;
263337
width: 16.5625rem;
264338
min-width: 11.25rem;
265339
max-width: calc(100vw - 24px);
@@ -346,34 +420,52 @@
346420
text-align: center;
347421
}
348422

349-
.ws-table-column-color-menu {
350-
z-index: 120;
423+
.ws-table-selection-menu {
424+
position: relative;
425+
z-index: 4;
426+
width: 12.5rem;
427+
min-width: 12.5rem;
428+
max-width: calc(100vw - 24px);
429+
border-radius: 0.875rem;
430+
box-shadow: 0 24px 60px -30px oklch(0 0 0 / 0.36);
431+
overflow: hidden;
432+
}
433+
434+
.ws-table-selection-menu-items {
435+
display: flex;
436+
flex-direction: column;
437+
gap: 1px;
438+
padding: 0.25rem;
439+
}
440+
441+
.ws-table-color-menu {
442+
z-index: 5;
351443
width: min(22rem, calc(100vw - 40px));
352-
border-radius: 1.25rem;
353-
padding: 0.5rem;
444+
border-radius: 0.25rem;
445+
padding: 0.25rem;
354446
box-shadow: 0 26px 64px -30px oklch(0 0 0 / 0.36);
355447
}
356448

357-
.ws-table-column-color-scroll {
449+
.ws-table-color-scroll {
358450
height: min(60vh, 32rem);
359451
max-height: min(60vh, 32rem);
360452
}
361453

362-
.ws-table-column-color-section {
454+
.ws-table-color-section {
363455
display: flex;
364456
flex-direction: column;
365457
gap: 0.25rem;
366458
padding: 0.25rem;
367459
}
368460

369-
.ws-table-column-color-title {
461+
.ws-table-color-title {
370462
padding: 0.35rem 0.45rem 0.55rem;
371463
font-size: 1.2rem;
372464
font-weight: 700;
373465
color: oklch(var(--foreground));
374466
}
375467

376-
.ws-table-column-color-item {
468+
.ws-table-color-item {
377469
display: inline-flex;
378470
width: 100%;
379471
align-items: center;
@@ -387,11 +479,11 @@
387479
transition: background-color 0.16s ease, color 0.16s ease;
388480
}
389481

390-
.ws-table-column-color-item:hover {
482+
.ws-table-color-item:hover {
391483
background: oklch(var(--accent));
392484
}
393485

394-
.ws-table-column-color-swatch {
486+
.ws-table-color-swatch {
395487
display: inline-flex;
396488
width: 3.9rem;
397489
height: 3.9rem;

0 commit comments

Comments
 (0)