Skip to content

Commit 620df2e

Browse files
authored
add tab scrolling and drag&drop (marktext#953)
* add tab scrolling and drag&drop * fix tab maximal width without side bar * use dragula instead of vue-draggable * Update changelog * fix issues with maximal side bar width If the side bar is resized more than 50vw then issues occur because the commited width is not limited to 50vw or if the window is resized. * reordered tabs after dropping and some improvements
1 parent 3b9c167 commit 620df2e

File tree

16 files changed

+550
-191
lines changed

16 files changed

+550
-191
lines changed

.github/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
**:cactus:Feature**
66

77
- The cursor jump to the end of format or to the next brackets when press `tab`(#976)
8+
- Tab drag & drop inside the window
9+
- Scrollable tabs
810

911
**:butterfly:Optimization**
1012

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@
170170
"codemirror": "^5.46.0",
171171
"command-exists": "^1.2.8",
172172
"dayjs": "^1.8.13",
173+
"dom-autoscroller": "^2.3.4",
173174
"dompurify": "^1.0.10",
175+
"dragula": "^3.7.2",
174176
"electron-is-accelerator": "^0.1.2",
175177
"element-resize-detector": "^1.2.0",
176178
"element-ui": "^2.8.2",

src/renderer/app.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@
152152
153153
// prevent Chromium's default behavior and try to open the first file
154154
window.addEventListener('dragover', e => {
155+
// Cancel to allow tab drag&drop.
156+
if (!e.dataTransfer.types.length) return
157+
155158
e.preventDefault()
156159
if (e.dataTransfer.types.indexOf('Files') >= 0) {
157160
if (e.dataTransfer.items.length === 1 && /png|jpg|jpeg|gif/.test(e.dataTransfer.items[0].type)) {
@@ -201,6 +204,7 @@
201204
}
202205
.editor-middle {
203206
display: flex;
207+
flex-direction: column;
204208
flex: 1;
205209
min-height: 100vh;
206210
position: relative;

src/renderer/assets/themes/dark.theme.css

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,27 @@
4848
}
4949

5050
.editor-tabs {
51-
border-bottom: 1px solid #1d1d1d;
5251
box-shadow: none !important;
5352
}
53+
.editor-tabs:after {
54+
position: absolute;
55+
content: '';
56+
border-bottom: 1px solid #1d1d1d;
57+
bottom: 0;
58+
left: 0;
59+
right: 0;
60+
z-index: 1;
61+
}
62+
.editor-tabs ul.tabs-container:after {
63+
position: absolute;
64+
content: '';
65+
border-bottom: 1px solid #1d1d1d;
66+
bottom: 0;
67+
left: 0;
68+
right: 0;
69+
z-index: 2;
70+
}
71+
5472
.tabs-container > li,
5573
.tabs-container > li.active {
5674
background: var(--editorBgColor) !important;

src/renderer/assets/themes/graphite.theme.css

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,32 @@
2727
--editorAreaWidth: 700px;
2828
}
2929

30-
.title-bar.tabs-visible {
31-
background: #f3f3f3 !important;
32-
}
33-
3430
.editor-tabs {
3531
background: #f3f3f3 !important;
36-
border-bottom: 1px solid #dddddd !important;
3732
box-shadow: none !important;
3833
}
34+
.editor-tabs:after {
35+
position: absolute;
36+
content: '';
37+
border-bottom: 1px solid #dddddd;
38+
bottom: 0;
39+
left: 0;
40+
right: 0;
41+
z-index: 1;
42+
}
43+
.editor-tabs ul.tabs-container:after {
44+
position: absolute;
45+
content: '';
46+
border-bottom: 1px solid #dddddd;
47+
bottom: 0;
48+
left: 0;
49+
right: 0;
50+
z-index: 2;
51+
}
52+
.title-bar-editor-bg.tabs-visible {
53+
background: #f3f3f3 !important;
54+
}
55+
3956
.tabs-container > li {
4057
background: none !important;
4158
}
@@ -45,7 +62,7 @@
4562
border-bottom: none;
4663
background: var(--floatBgColor) !important;
4764
}
48-
.tabs-container > li.active:not(:last-child):after {
65+
.tabs-container > li.active:after {
4966
top: 0 !important;
5067
bottom: auto !important;
5168
background: var(--themeColor) !important;

src/renderer/assets/themes/one-dark.theme.css

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,27 @@
110110
}
111111

112112
.editor-tabs {
113-
border-bottom: 1px solid #181a1f;
114113
box-shadow: none !important;
115114
}
115+
.editor-tabs:after {
116+
position: absolute;
117+
content: '';
118+
border-bottom: 1px solid #181a1f;
119+
bottom: 0;
120+
left: 0;
121+
right: 0;
122+
z-index: 1;
123+
}
124+
.editor-tabs ul.tabs-container:after {
125+
position: absolute;
126+
content: '';
127+
border-bottom: 1px solid #181a1f;
128+
bottom: 0;
129+
left: 0;
130+
right: 0;
131+
z-index: 2;
132+
}
133+
116134
.tabs-container > li,
117135
.tabs-container > li.active {
118136
background: var(--editorBgColor) !important;
@@ -121,7 +139,7 @@
121139
border: 1px solid #181a1f;
122140
border-bottom: none;
123141
}
124-
.tabs-container > li.active:not(:last-child):after {
142+
.tabs-container > li.active:after {
125143
top: 0 !important;
126144
right: auto !important;
127145
width: 2px !important;

src/renderer/assets/themes/ulysses.theme.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
box-shadow: none !important;
3232
}
3333

34-
.tabs-container > li:not(:last-child) {
34+
.tabs-container > li {
3535
border-right: 1px solid #e5e5e5 !important;
3636
background: var(--editorBgColor) !important;
3737
}

src/renderer/components/editorWithTabs/index.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,12 @@
6868

6969
<style scoped>
7070
.editor-with-tabs {
71-
width: 100%;
71+
position: relative;
7272
height: 100%;
73-
padding-top: var(--titleBarHeight);
7473
flex: 1;
7574
display: flex;
7675
flex-direction: column;
77-
76+
7877
overflow: hidden;
7978
background: var(--editorBgColor);
8079
& > .container {

0 commit comments

Comments
 (0)