Skip to content

Commit

Permalink
Lexical: Added dark mode styles, fixed autolink range
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddanbrown committed Dec 14, 2024
1 parent 97b201f commit a71aa24
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
4 changes: 2 additions & 2 deletions resources/js/wysiwyg/services/__tests__/auto-links.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Auto-link service tests', () => {
pNode.append(text);
$getRoot().append(pNode);

text.select(35, 35);
text.select(34, 34);
});

editor.commitUpdates();
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('Auto-link service tests', () => {
pNode.append(text);
$getRoot().append(pNode);

text.select(35, 35);
text.select(34, 34);
});

editor.commitUpdates();
Expand Down
2 changes: 1 addition & 1 deletion resources/js/wysiwyg/services/auto-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function handlePotentialLinkEvent(node: TextNode, selection: BaseSelection, edit
return;
}

const cursorPoint = selectionRange[0].offset - 1;
const cursorPoint = selectionRange[0].offset;
const nodeText = node.getTextContent();
const rTrimText = nodeText.slice(0, cursorPoint);
const priorSpaceIndex = rTrimText.lastIndexOf(' ');
Expand Down
47 changes: 30 additions & 17 deletions resources/sass/_editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@

// Main UI elements
.editor-container {
background-color: #FFF;
@include mixins.lightDark(background-color, #FFF, #222);
position: relative;
&.fullscreen {
z-index: 500;
}
}

.editor-toolbar-main {
display: flex;
flex-wrap: wrap;
justify-content: center;
border-top: 1px solid #DDD;
border-bottom: 1px solid #DDD;
@include mixins.lightDark(border-color, #DDD, #000);
}

body.editor-is-fullscreen {
Expand All @@ -46,6 +48,7 @@ body.editor-is-fullscreen {
font-size: 12px;
padding: 4px;
color: #444;
@include mixins.lightDark(color, #444, #999);
border-radius: 4px;
display: flex;
align-items: center;
Expand All @@ -54,6 +57,7 @@ body.editor-is-fullscreen {
}
.editor-button:hover {
background-color: #EEE;
@include mixins.lightDark(background-color, #EEE, #333);
cursor: pointer;
color: #000;
}
Expand All @@ -63,7 +67,7 @@ body.editor-is-fullscreen {
opacity: .6;
}
.editor-button-active, .editor-button-active:hover {
background-color: #ceebff;
@include mixins.lightDark(background-color, #ceebff, #444);
color: #000;
}
.editor-button-long {
Expand All @@ -75,7 +79,7 @@ body.editor-is-fullscreen {
}
.editor-button-text {
font-weight: 400;
color: #000;
@include mixins.lightDark(color, #000, #AAA);
font-size: 14px;
flex: 1;
padding-inline-end: 4px;
Expand Down Expand Up @@ -126,7 +130,8 @@ body.editor-is-fullscreen {
}
}
&:hover {
outline: 1px solid #DDD;
outline: 1px solid;
@include mixins.lightDark(outline-color, #DDD, #111);
outline-offset: -3px;
}
}
Expand All @@ -137,11 +142,14 @@ body.editor-is-fullscreen {
}
.editor-dropdown-menu {
position: absolute;
background-color: #FFF;
box-shadow: 0 0 6px 0 rgba(0, 0, 0, 0.15);
border: 1px solid;
@include mixins.lightDark(background-color, #FFF, #292929);
@include mixins.lightDark(border-color, #FFF, #333);
@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));
z-index: 99;
display: flex;
flex-direction: row;
border-radius: 3px;
}
.editor-dropdown-menu-vertical {
display: flex;
Expand All @@ -163,8 +171,8 @@ body.editor-is-fullscreen {
.editor-separator {
display: block;
height: 1px;
background-color: #DDD;
opacity: .8;
@include mixins.lightDark(background-color, #DDD, #000);
}

.editor-format-menu-toggle {
Expand Down Expand Up @@ -199,6 +207,7 @@ body.editor-is-fullscreen {
display: flex;
border-inline: 1px solid #DDD;
padding-inline: 4px;
@include mixins.lightDark(border-color, #DDD, #000);
&:first-child {
border-inline-start: none;
}
Expand All @@ -212,11 +221,12 @@ body.editor-is-fullscreen {

.editor-context-toolbar {
position: fixed;
background-color: #FFF;
border: 1px solid #DDD;
@include mixins.lightDark(background-color, #FFF, #222);
@include mixins.lightDark(border-color, #DDD, #333);
@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));
padding: .2rem;
border-radius: 4px;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12);
display: flex;
flex-direction: row;
&:before {
Expand All @@ -226,9 +236,10 @@ body.editor-is-fullscreen {
width: 8px;
height: 8px;
position: absolute;
background-color: #FFF;
@include mixins.lightDark(background-color, #FFF, #222);
border-top: 1px solid #DDD;
border-left: 1px solid #DDD;
@include mixins.lightDark(border-color, #DDD, #333);
transform: rotate(45deg);
left: 50%;
margin-left: -4px;
Expand All @@ -252,7 +263,7 @@ body.editor-is-fullscreen {
height: 100%;
}
.editor-modal {
background-color: #FFF;
@include mixins.lightDark(background-color, #FFF, #222);
border-radius: 4px;
overflow: hidden;
box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.3);
Expand Down Expand Up @@ -314,7 +325,8 @@ body.editor-is-fullscreen {
display: flex;
}
.editor-table-creator-cell {
border: 1px solid #DDD;
border: 1px solid;
@include mixins.lightDark(border-color, #DDD, #000);
width: 15px;
height: 15px;
cursor: pointer;
Expand Down Expand Up @@ -347,7 +359,7 @@ body.editor-is-fullscreen {
height: 10px;
border: 2px solid var(--editor-color-primary);
z-index: 3;
background-color: #FFF;
@include mixins.lightDark(background-color, #FFF, #000);
user-select: none;
&.nw {
inset-inline-start: -5px;
Expand Down Expand Up @@ -477,10 +489,11 @@ body.editor-is-fullscreen {
display: block;
width: 100%;
min-width: 250px;
border: 1px solid #DDD;
border: 1px solid;
@include mixins.lightDark(border-color, #DDD, #000);
padding: .5rem;
border-radius: 4px;
color: #444;
@include mixins.lightDark(color, #444, #BBB);
}
textarea.editor-form-field-input {
font-family: var(--font-code);
Expand Down Expand Up @@ -557,15 +570,15 @@ textarea.editor-form-field-input {
.editor-form-tab-control {
font-weight: bold;
font-size: 14px;
color: #444;
@include mixins.lightDark(color, #444, #666);
border-bottom: 2px solid transparent;
position: relative;
cursor: pointer;
padding: .25rem .5rem;
text-align: start;
&[aria-selected="true"] {
border-color: var(--editor-color-primary);
color: var(--editor-color-primary);
color: var(--editor-color-primary) !important;
}
&[aria-selected="true"]:after, &:hover:after {
background-color: var(--editor-color-primary);
Expand Down

0 comments on commit a71aa24

Please sign in to comment.