-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(EditorView): change default selection styles
- Loading branch information
1 parent
89c9881
commit f3b5c46
Showing
4 changed files
with
123 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,80 @@ | ||
@use '../../../../node_modules/prosemirror-view/style/prosemirror'; | ||
$active-node-default-indent-top: calc(-1 * var(--g-spacing-1)); | ||
$active-node-default-indent-bottom: calc(-1 * var(--g-spacing-1)); | ||
$active-node-default-indent-left: calc(-1 * var(--g-spacing-2)); | ||
$active-node-default-indent-right: calc(-1 * var(--g-spacing-2)); | ||
|
||
// Make outline appear only if ProseMirror is focused | ||
$active-node-selector: '.pm-node-selected'; | ||
$basic-elements: h1, h2, h3, h4, h5, h6, p, ul, ol, span, pre, '*[data-html], .g-md-checkbox'; | ||
|
||
.ProseMirror-selectednode { | ||
outline: none; | ||
$default-selection-border: none; | ||
$default-selection-border-radius: var(--g-border-radius-m); | ||
$default-selection-outline: none; | ||
// TODO: CHANGE TO TOKEN | ||
$default-selection-background: #e6e6e6; | ||
$default-selection-box-shadow: none; | ||
|
||
$default-li-marker-width: var(--g-spacing-4); | ||
|
||
@mixin node-props { | ||
position: relative; | ||
|
||
border: $default-selection-border; | ||
border-radius: $default-selection-border-radius; | ||
outline: $default-selection-outline; | ||
background: var(--g-selection-background, $default-selection-background); | ||
box-shadow: $default-selection-box-shadow; | ||
} | ||
|
||
.li.ProseMirror-selectednode:after { | ||
border: none; | ||
@mixin selection-props { | ||
border: var(--g-selection-border, $default-selection-border); | ||
border-radius: var(--g-selection-border-radius, $default-selection-border-radius); | ||
outline: var(--g-selection-outline, $default-selection-outline); | ||
background: var(--g-selection-background, $default-selection-background); | ||
box-shadow: var(--g-selection-box-shadow, $default-selection-box-shadow); | ||
} | ||
|
||
.g-md-editor.ProseMirror-focused { | ||
.ProseMirror-selectednode { | ||
outline: 2px solid #8cf; | ||
} | ||
[class].g-md-editor { | ||
@each $basic-element in $basic-elements { | ||
& #{$basic-element}#{$active-node-selector} { | ||
@include node-props; | ||
|
||
&::after { | ||
position: absolute; | ||
z-index: -1; | ||
inset: $active-node-default-indent-top | ||
$active-node-default-indent-right | ||
$active-node-default-indent-bottom | ||
$active-node-default-indent-left; | ||
|
||
content: ''; | ||
|
||
li.ProseMirror-selectednode:after { | ||
border: 2px solid #8cf; | ||
@include selection-props; | ||
} | ||
|
||
& img { | ||
mix-blend-mode: multiply; | ||
} | ||
} | ||
} | ||
} | ||
|
||
.g-md-editor.ProseMirror, | ||
.g-md-editor .ProseMirror { | ||
&:focus { | ||
outline: none; | ||
& li#{$active-node-selector} { | ||
@include node-props; | ||
|
||
&::marker { | ||
@include selection-props; | ||
} | ||
|
||
&::after { | ||
position: absolute; | ||
z-index: -1; | ||
inset: $active-node-default-indent-top | ||
$active-node-default-indent-right | ||
$active-node-default-indent-bottom | ||
calc($active-node-default-indent-left - max(var(--li-marker-width, 0), $default-li-marker-width)); | ||
|
||
content: ''; | ||
|
||
@include selection-props; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters