]> BookStack Code Mirror - bookstack/commitdiff
Lexical: Added dark mode styles, fixed autolink range
authorDan Brown <redacted>
Sat, 14 Dec 2024 15:17:33 +0000 (15:17 +0000)
committerDan Brown <redacted>
Sat, 14 Dec 2024 15:17:33 +0000 (15:17 +0000)
resources/js/wysiwyg/services/__tests__/auto-links.test.ts
resources/js/wysiwyg/services/auto-links.ts
resources/sass/_editor.scss

index d3b120b706431a2e72577d3bb27e88d4ee1d20fc..30dc925659ef2475309b9fb712f79a06692648f9 100644 (file)
@@ -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();
@@ -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();
index 44a78ec8577c819c021f69d1e93bf0197921127c..1c3b1c73010c750f121ca0e81c05ce6c9965d198 100644 (file)
@@ -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(' ');
index e273f1942d54b62b435034bc5904a9bc7594a35c..bdf6ea44c3db84a6054e739a941b798a50f7becd 100644 (file)
@@ -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 {
@@ -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;
@@ -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;
 }
@@ -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 {
@@ -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;
@@ -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;
   }
 }
@@ -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;
@@ -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 {
@@ -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;
   }
@@ -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 {
@@ -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;
@@ -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);
@@ -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;
@@ -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;
@@ -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);
@@ -557,7 +570,7 @@ 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;
@@ -565,7 +578,7 @@ textarea.editor-form-field-input {
   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);