Skip to content

Commit a71aa24

Browse files
committed
Lexical: Added dark mode styles, fixed autolink range
1 parent 97b201f commit a71aa24

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

resources/js/wysiwyg/services/__tests__/auto-links.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Auto-link service tests', () => {
2424
pNode.append(text);
2525
$getRoot().append(pNode);
2626

27-
text.select(35, 35);
27+
text.select(34, 34);
2828
});
2929

3030
editor.commitUpdates();
@@ -62,7 +62,7 @@ describe('Auto-link service tests', () => {
6262
pNode.append(text);
6363
$getRoot().append(pNode);
6464

65-
text.select(35, 35);
65+
text.select(34, 34);
6666
});
6767

6868
editor.commitUpdates();

resources/js/wysiwyg/services/auto-links.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function handlePotentialLinkEvent(node: TextNode, selection: BaseSelection, edit
2727
return;
2828
}
2929

30-
const cursorPoint = selectionRange[0].offset - 1;
30+
const cursorPoint = selectionRange[0].offset;
3131
const nodeText = node.getTextContent();
3232
const rTrimText = nodeText.slice(0, cursorPoint);
3333
const priorSpaceIndex = rTrimText.lastIndexOf(' ');

resources/sass/_editor.scss

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@
88

99
// Main UI elements
1010
.editor-container {
11-
background-color: #FFF;
11+
@include mixins.lightDark(background-color, #FFF, #222);
1212
position: relative;
1313
&.fullscreen {
1414
z-index: 500;
1515
}
1616
}
17+
1718
.editor-toolbar-main {
1819
display: flex;
1920
flex-wrap: wrap;
2021
justify-content: center;
2122
border-top: 1px solid #DDD;
2223
border-bottom: 1px solid #DDD;
24+
@include mixins.lightDark(border-color, #DDD, #000);
2325
}
2426

2527
body.editor-is-fullscreen {
@@ -46,6 +48,7 @@ body.editor-is-fullscreen {
4648
font-size: 12px;
4749
padding: 4px;
4850
color: #444;
51+
@include mixins.lightDark(color, #444, #999);
4952
border-radius: 4px;
5053
display: flex;
5154
align-items: center;
@@ -54,6 +57,7 @@ body.editor-is-fullscreen {
5457
}
5558
.editor-button:hover {
5659
background-color: #EEE;
60+
@include mixins.lightDark(background-color, #EEE, #333);
5761
cursor: pointer;
5862
color: #000;
5963
}
@@ -63,7 +67,7 @@ body.editor-is-fullscreen {
6367
opacity: .6;
6468
}
6569
.editor-button-active, .editor-button-active:hover {
66-
background-color: #ceebff;
70+
@include mixins.lightDark(background-color, #ceebff, #444);
6771
color: #000;
6872
}
6973
.editor-button-long {
@@ -75,7 +79,7 @@ body.editor-is-fullscreen {
7579
}
7680
.editor-button-text {
7781
font-weight: 400;
78-
color: #000;
82+
@include mixins.lightDark(color, #000, #AAA);
7983
font-size: 14px;
8084
flex: 1;
8185
padding-inline-end: 4px;
@@ -126,7 +130,8 @@ body.editor-is-fullscreen {
126130
}
127131
}
128132
&:hover {
129-
outline: 1px solid #DDD;
133+
outline: 1px solid;
134+
@include mixins.lightDark(outline-color, #DDD, #111);
130135
outline-offset: -3px;
131136
}
132137
}
@@ -137,11 +142,14 @@ body.editor-is-fullscreen {
137142
}
138143
.editor-dropdown-menu {
139144
position: absolute;
140-
background-color: #FFF;
141-
box-shadow: 0 0 6px 0 rgba(0, 0, 0, 0.15);
145+
border: 1px solid;
146+
@include mixins.lightDark(background-color, #FFF, #292929);
147+
@include mixins.lightDark(border-color, #FFF, #333);
148+
@include mixins.lightDark(box-shadow, 0 0 6px 0 rgba(0, 0, 0, 0.15), 0 1px 4px 0 rgba(0, 0, 0, 0.4));
142149
z-index: 99;
143150
display: flex;
144151
flex-direction: row;
152+
border-radius: 3px;
145153
}
146154
.editor-dropdown-menu-vertical {
147155
display: flex;
@@ -163,8 +171,8 @@ body.editor-is-fullscreen {
163171
.editor-separator {
164172
display: block;
165173
height: 1px;
166-
background-color: #DDD;
167174
opacity: .8;
175+
@include mixins.lightDark(background-color, #DDD, #000);
168176
}
169177

170178
.editor-format-menu-toggle {
@@ -199,6 +207,7 @@ body.editor-is-fullscreen {
199207
display: flex;
200208
border-inline: 1px solid #DDD;
201209
padding-inline: 4px;
210+
@include mixins.lightDark(border-color, #DDD, #000);
202211
&:first-child {
203212
border-inline-start: none;
204213
}
@@ -212,11 +221,12 @@ body.editor-is-fullscreen {
212221

213222
.editor-context-toolbar {
214223
position: fixed;
215-
background-color: #FFF;
216224
border: 1px solid #DDD;
225+
@include mixins.lightDark(background-color, #FFF, #222);
226+
@include mixins.lightDark(border-color, #DDD, #333);
227+
@include mixins.lightDark(box-shadow, 0 2px 4px 0 rgba(0, 0, 0, 0.12), 0 1px 4px 0 rgba(0, 0, 0, 0.4));
217228
padding: .2rem;
218229
border-radius: 4px;
219-
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12);
220230
display: flex;
221231
flex-direction: row;
222232
&:before {
@@ -226,9 +236,10 @@ body.editor-is-fullscreen {
226236
width: 8px;
227237
height: 8px;
228238
position: absolute;
229-
background-color: #FFF;
239+
@include mixins.lightDark(background-color, #FFF, #222);
230240
border-top: 1px solid #DDD;
231241
border-left: 1px solid #DDD;
242+
@include mixins.lightDark(border-color, #DDD, #333);
232243
transform: rotate(45deg);
233244
left: 50%;
234245
margin-left: -4px;
@@ -252,7 +263,7 @@ body.editor-is-fullscreen {
252263
height: 100%;
253264
}
254265
.editor-modal {
255-
background-color: #FFF;
266+
@include mixins.lightDark(background-color, #FFF, #222);
256267
border-radius: 4px;
257268
overflow: hidden;
258269
box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.3);
@@ -314,7 +325,8 @@ body.editor-is-fullscreen {
314325
display: flex;
315326
}
316327
.editor-table-creator-cell {
317-
border: 1px solid #DDD;
328+
border: 1px solid;
329+
@include mixins.lightDark(border-color, #DDD, #000);
318330
width: 15px;
319331
height: 15px;
320332
cursor: pointer;
@@ -347,7 +359,7 @@ body.editor-is-fullscreen {
347359
height: 10px;
348360
border: 2px solid var(--editor-color-primary);
349361
z-index: 3;
350-
background-color: #FFF;
362+
@include mixins.lightDark(background-color, #FFF, #000);
351363
user-select: none;
352364
&.nw {
353365
inset-inline-start: -5px;
@@ -477,10 +489,11 @@ body.editor-is-fullscreen {
477489
display: block;
478490
width: 100%;
479491
min-width: 250px;
480-
border: 1px solid #DDD;
492+
border: 1px solid;
493+
@include mixins.lightDark(border-color, #DDD, #000);
481494
padding: .5rem;
482495
border-radius: 4px;
483-
color: #444;
496+
@include mixins.lightDark(color, #444, #BBB);
484497
}
485498
textarea.editor-form-field-input {
486499
font-family: var(--font-code);
@@ -557,15 +570,15 @@ textarea.editor-form-field-input {
557570
.editor-form-tab-control {
558571
font-weight: bold;
559572
font-size: 14px;
560-
color: #444;
573+
@include mixins.lightDark(color, #444, #666);
561574
border-bottom: 2px solid transparent;
562575
position: relative;
563576
cursor: pointer;
564577
padding: .25rem .5rem;
565578
text-align: start;
566579
&[aria-selected="true"] {
567580
border-color: var(--editor-color-primary);
568-
color: var(--editor-color-primary);
581+
color: var(--editor-color-primary) !important;
569582
}
570583
&[aria-selected="true"]:after, &:hover:after {
571584
background-color: var(--editor-color-primary);

0 commit comments

Comments
 (0)