Skip to content

Commit 5a6d835

Browse files
committed
feat(texteditor): add minimize buttons to toolbars
1 parent 0690fcf commit 5a6d835

8 files changed

Lines changed: 90 additions & 41 deletions

File tree

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/TipTapEditor.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99
<EditorToolbar
1010
v-if="!isMobile"
1111
v-on="sharedEventHandlers"
12+
@minimize="emitMinimize"
1213
/>
1314

1415
<div v-else>
15-
<MobileTopBar v-on="sharedEventHandlers" />
16+
<MobileTopBar
17+
v-on="sharedEventHandlers"
18+
@minimize="emitMinimize"
19+
/>
1620
<MobileFormattingBar
1721
v-if="isFocused"
1822
v-on="sharedEventHandlers"
@@ -245,6 +249,13 @@
245249
imageHandler,
246250
sharedEventHandlers,
247251
editorMode: computed(() => props.mode),
252+
emitMinimize: () => {
253+
// force lose focus
254+
if (editor.value) {
255+
emit('minimize');
256+
editor.value.commands.blur();
257+
}
258+
},
248259
};
249260
},
250261
props: {

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/components/EditorToolbar.vue

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
/>
115115
</div>
116116

117-
<ToolbarDivider v-if="visibleCategories.includes('scripts')" />
117+
<ToolbarDivider v-if="visibleCategories.includes('script')" />
118118

119119
<!-- Insert tools -->
120120
<div
@@ -271,6 +271,11 @@
271271
</template>
272272
</div>
273273
</div>
274+
<ToolbarButton
275+
:title="minimizeAction.title"
276+
:icon="minimizeAction.icon"
277+
@click="minimizeAction.handler"
278+
/>
274279
</div>
275280

276281
</template>
@@ -303,10 +308,10 @@
303308
// TODO: Maybe these shouldnt be hardcoded?
304309
const OVERFLOW_BREAKPOINTS = {
305310
insert: 750,
306-
script: 650,
307-
lists: 550,
308-
clearFormat: 450,
309-
clipboard: 405,
311+
script: 660,
312+
lists: 600,
313+
clearFormat: 500,
314+
clipboard: 465,
310315
};
311316
312317
// Categories that can overflow (in order of overflow priority)
@@ -321,7 +326,8 @@
321326
listActions,
322327
scriptActions,
323328
insertTools,
324-
} = useToolbarActions();
329+
minimizeAction,
330+
} = useToolbarActions(emit);
325331
326332
const { pasteOptions } = useDropdowns();
327333
@@ -472,6 +478,7 @@
472478
listActions,
473479
scriptActions,
474480
insertTools,
481+
minimizeAction,
475482
pasteOptions,
476483
copy$,
477484
textFormattingToolbar$,
@@ -495,14 +502,18 @@
495502
.toolbar {
496503
position: relative;
497504
display: flex;
498-
gap: 4px;
505+
gap: 6px;
499506
align-items: center;
500-
padding: 8px 4px;
507+
padding: 8px;
501508
background: #f8f9fa;
502509
border-bottom: 1px solid #e1e5e9;
503510
border-radius: 8px 8px 0 0;
504511
}
505512
513+
.toolbar > :last-child {
514+
margin-left: auto;
515+
}
516+
506517
[role='group'] {
507518
display: flex;
508519
gap: 2px;
@@ -581,10 +592,4 @@
581592
}
582593
}
583594
584-
@media (max-width: 820px) {
585-
.toolbar {
586-
gap: 1px;
587-
}
588-
}
589-
590595
</style>

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/components/toolbar/FormatDropdown.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
gap: 8px;
212212
align-items: center;
213213
justify-content: space-between;
214-
min-width: 80px;
214+
min-width: 100px;
215215
padding: 6px 8px;
216216
font-size: 14px;
217217
color: #495057;

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/components/toolbar/MobileTopBar.vue

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22

33
<div
4-
class="top-bar"
4+
class="toolbar top-bar"
55
role="toolbar"
66
aria-label="Editor controls"
77
>
@@ -21,17 +21,24 @@
2121
</div>
2222

2323
<div class="insert-container">
24-
<button
25-
class="insert-button"
26-
title="Insert content"
27-
aria-label="Insert content menu"
28-
:aria-expanded="isInsertMenuOpen"
29-
aria-haspopup="menu"
30-
aria-controls="insert-menu"
31-
@click="isInsertMenuOpen = !isInsertMenuOpen"
32-
>
33-
+
34-
</button>
24+
<div class="topbar-actions">
25+
<button
26+
class="insert-button"
27+
title="Insert content"
28+
aria-label="Insert content menu"
29+
:aria-expanded="isInsertMenuOpen"
30+
aria-haspopup="menu"
31+
aria-controls="insert-menu"
32+
@click="isInsertMenuOpen = !isInsertMenuOpen"
33+
>
34+
+
35+
</button>
36+
<ToolbarButton
37+
:title="minimizeAction.title"
38+
:icon="minimizeAction.icon"
39+
@click="minimizeAction.handler"
40+
/>
41+
</div>
3542

3643
<div
3744
v-if="isInsertMenuOpen"
@@ -76,7 +83,7 @@
7683
const isInsertMenuOpen = ref(false);
7784
const dropdown = ref(null);
7885
79-
const { historyActions, insertTools } = useToolbarActions(emit);
86+
const { historyActions, insertTools, minimizeAction } = useToolbarActions(emit);
8087
8188
const handleClickOutside = event => {
8289
if (
@@ -100,6 +107,7 @@
100107
return {
101108
historyActions,
102109
insertTools,
110+
minimizeAction,
103111
isInsertMenuOpen,
104112
dropdown,
105113
};
@@ -113,7 +121,8 @@
113121
114122
.top-bar {
115123
display: flex;
116-
flex-shrink: 0;
124+
125+
/* flex-shrink: 0; */
117126
align-items: center;
118127
justify-content: space-between;
119128
padding: 0.5rem;
@@ -125,25 +134,35 @@
125134
gap: 0.25rem;
126135
}
127136
137+
.topbar-actions {
138+
display: flex;
139+
gap: 1rem;
140+
align-items: center;
141+
}
142+
128143
.insert-container {
129144
position: relative;
130145
}
131146
132147
.insert-button {
148+
display: flex;
149+
align-items: center;
150+
justify-content: center;
133151
width: 36px;
134152
min-width: 44px;
135153
height: 36px;
136154
min-height: 44px;
137-
font-size: 1.6rem;
155+
font-size: 2.5rem;
138156
color: #666666;
139157
cursor: pointer;
158+
opacity: 0.8;
140159
}
141160
142161
.insert-dropdown {
143162
position: absolute;
144163
top: calc(100% + 8px);
145164
right: 0;
146-
z-index: 10;
165+
z-index: 2;
147166
width: 200px;
148167
padding: 0.5rem 0;
149168
background: white;

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/components/toolbar/PasteDropdown.vue

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@
262262
}
263263
264264
.toolbar-icon {
265-
width: 17px;
266-
height: 17px;
265+
width: 20px;
266+
height: 20px;
267267
opacity: 0.7;
268268
}
269269
@@ -306,8 +306,8 @@
306306
}
307307
308308
.dropdown-arrow {
309-
width: 12px;
310-
height: 12px;
309+
width: 15px;
310+
height: 15px;
311311
opacity: 0.9;
312312
}
313313
@@ -340,7 +340,6 @@
340340
BlinkMacSystemFont,
341341
'Segoe UI',
342342
sans-serif;
343-
font-size: 14px;
344343
line-height: 140%;
345344
color: #000000;
346345
cursor: pointer;
@@ -359,8 +358,8 @@
359358
}
360359
361360
.dropdown-item-icon {
362-
width: 16px;
363-
height: 16px;
361+
width: 18px;
362+
height: 18px;
364363
opacity: 0.7;
365364
}
366365

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/components/toolbar/ToolbarButton.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@
133133
}
134134
135135
.toolbar-icon {
136-
width: 21px;
137-
height: 21px;
136+
width: 1.7rem;
137+
height: 1.7rem;
138138
opacity: 0.7;
139139
}
140140

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/composables/useToolbarActions.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ export function useToolbarActions(emit) {
241241
}
242242
};
243243

244+
const handleMinimize = () => {
245+
emit('minimize');
246+
};
247+
244248
// Helper function to check if a mark is active
245249
const isMarkActive = markName => {
246250
return editor?.value?.isActive(markName) || false;
@@ -393,6 +397,13 @@ export function useToolbarActions(emit) {
393397
},
394398
]);
395399

400+
const minimizeAction = {
401+
name: 'minimize',
402+
title: 'Minimize Toolbar',
403+
icon: require('../../assets/icon-unfold.svg'),
404+
handler: handleMinimize,
405+
};
406+
396407
return {
397408
// Individual handlers
398409
handleUndo,
@@ -422,5 +433,6 @@ export function useToolbarActions(emit) {
422433
listActions,
423434
scriptActions,
424435
insertTools,
436+
minimizeAction,
425437
};
426438
}
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)