-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(EditorView): changed default selection styles #520
Closed
whiteformed
wants to merge
6
commits into
gravity-ui:main
from
whiteformed:feat/change-default-selection-styles
Closed
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0ae5e41
feat(EditorView): change default selection styles
whiteformed c2ba786
feat(EditorView): change default selection variable names
whiteformed 70f1fcf
feat(EditorView): add selection styles for default elements
whiteformed 90f400f
feat(EditorView): unify selection styles
whiteformed 0f513ac
feat(EditorView): remove text highlight from selected nodes
whiteformed eece3e2
feat(EditorView): bring prosemirror styles back
whiteformed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,30 @@ export const Story: StoryObj<typeof component> = { | |
control: {type: 'text'}, | ||
description: 'Editor contents padding', | ||
}, | ||
'--g-selection-bg-color': { | ||
control: {type: 'text'}, | ||
description: 'Editor selection bg color', | ||
}, | ||
'--g-selection-border': { | ||
control: {type: 'text'}, | ||
description: 'Editor selection border', | ||
}, | ||
'--g-selection-border-radius': { | ||
control: {type: 'text'}, | ||
description: 'Editor selection border radius', | ||
}, | ||
'--g-selection-outline': { | ||
control: {type: 'text'}, | ||
description: 'Editor selection outline', | ||
}, | ||
'--g-selection-background': { | ||
control: {type: 'text'}, | ||
description: 'Editor selection background', | ||
}, | ||
'--g-selection-box-shadow': { | ||
control: {type: 'text'}, | ||
description: 'Editor selection box-shadow', | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's change css-vars to |
||
}, | ||
}; | ||
Story.storyName = 'Custom CSS Variables'; | ||
|
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 was deleted.
Oops, something went wrong.
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,3 +1,103 @@ | ||
.g-md-editor.ProseMirror-focused .pm-node-selected { | ||
box-shadow: var(--g-color-text-info) 0 0 0 1px; | ||
$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)); | ||
|
||
$active-node-selector: '.pm-node-selected'; | ||
$basic-elements: h1, h2, h3, h4, h5, h6, p, ul, ol, span, pre, '*[data-html]', '.g-md-checkbox', '.g-md-table-wrapper'; | ||
$yfm-elements: 'div[class^="yfm-"]'; | ||
|
||
$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; | ||
} | ||
|
||
@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); | ||
} | ||
|
||
[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: ''; | ||
|
||
@include selection-props; | ||
} | ||
|
||
& img { | ||
mix-blend-mode: multiply; | ||
} | ||
} | ||
|
||
} | ||
|
||
& #{$yfm-elements}#{$active-node-selector} { | ||
position: relative; | ||
|
||
&::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: ''; | ||
|
||
@include selection-props; | ||
} | ||
} | ||
|
||
& 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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--g-selection-bg-color
and--g-selection-background
– are these duplicate variables?