mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 06:43:44 +08:00
df90c7f0c1
This fixes an issue where, on a textarea with a lot of text, the cursor would jump when adding a new line. See video in PR for a repro. This is a Chrome bug with scroll anchoring. Refs: https://bugs.chromium.org/p/chromium/issues/detail?id=997266 The fix here disables `overflow-anchor` on the composer textarea. There should be no side effects to this change, as scroll anchoring is likely not needed for the composer textarea element.
373 lines
6.5 KiB
SCSS
373 lines
6.5 KiB
SCSS
.d-editor-container {
|
|
display: flex;
|
|
flex-grow: 1;
|
|
max-width: 100%;
|
|
|
|
&.has-form-template {
|
|
.d-editor-preview-wrapper {
|
|
display: none;
|
|
flex: 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
.d-editor {
|
|
display: flex;
|
|
flex-grow: 1;
|
|
min-height: 0;
|
|
}
|
|
|
|
.d-editor-textarea-column {
|
|
display: flex;
|
|
flex: 1;
|
|
flex-direction: column;
|
|
max-width: 100%;
|
|
min-width: 0;
|
|
}
|
|
|
|
.d-editor-textarea-wrapper {
|
|
display: flex;
|
|
flex: 1;
|
|
flex-direction: column;
|
|
background-color: var(--secondary);
|
|
position: relative;
|
|
border: 1px solid var(--primary-medium);
|
|
border-radius: var(--d-input-border-radius);
|
|
min-height: 0;
|
|
|
|
textarea {
|
|
background: transparent;
|
|
}
|
|
|
|
&.in-focus {
|
|
@include default-focus;
|
|
|
|
textarea {
|
|
outline: 0;
|
|
}
|
|
}
|
|
|
|
&.disabled {
|
|
cursor: not-allowed;
|
|
.d-editor-button-bar {
|
|
opacity: 0.5;
|
|
pointer-events: none;
|
|
}
|
|
}
|
|
}
|
|
|
|
.d-editor-preview-wrapper {
|
|
display: flex;
|
|
flex: 1;
|
|
flex-direction: column;
|
|
margin-left: 16px;
|
|
overflow: auto;
|
|
overflow-anchor: none;
|
|
cursor: default;
|
|
-webkit-overflow-scrolling: touch;
|
|
overscroll-behavior: contain;
|
|
}
|
|
|
|
.d-editor-input,
|
|
.d-editor-preview {
|
|
box-sizing: border-box;
|
|
flex: 1 1 100%;
|
|
width: 100%;
|
|
margin: 0;
|
|
min-height: auto;
|
|
word-wrap: break-word;
|
|
-webkit-appearance: none;
|
|
border-radius: 0;
|
|
}
|
|
|
|
.d-editor-input {
|
|
border: 0;
|
|
padding: 10px;
|
|
height: 100%;
|
|
overflow-x: hidden;
|
|
overscroll-behavior: contain;
|
|
overflow-anchor: none;
|
|
resize: none;
|
|
}
|
|
|
|
.d-editor-preview {
|
|
height: auto;
|
|
}
|
|
|
|
.d-editor-plugin {
|
|
display: flex;
|
|
flex: 1 1;
|
|
overflow: auto;
|
|
}
|
|
|
|
.composing-whisper .d-editor-preview {
|
|
font-style: italic;
|
|
color: var(--primary-medium) !important;
|
|
}
|
|
|
|
.hide-preview .d-editor-preview-wrapper {
|
|
display: none;
|
|
flex: 0;
|
|
}
|
|
|
|
.edit-category-tab-topic-template {
|
|
.emoji.btn {
|
|
display: none;
|
|
}
|
|
}
|
|
|
|
.user-preferences .bio-composer,
|
|
.group-form-bio,
|
|
.edit-category-tab-topic-template {
|
|
textarea {
|
|
width: 100%;
|
|
height: 100%;
|
|
min-height: 10em;
|
|
}
|
|
.local-dates.btn {
|
|
display: none;
|
|
}
|
|
.d-editor-container {
|
|
display: block;
|
|
}
|
|
.d-editor-textarea-wrapper {
|
|
border: 1px solid var(--primary-low);
|
|
}
|
|
.d-editor-preview-wrapper {
|
|
max-width: 100%;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
.d-editor-preview {
|
|
background-color: var(--primary-very-low);
|
|
margin-top: 1em;
|
|
padding: 0.667em;
|
|
&:empty {
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
.user-preferences .bio-composer,
|
|
.group-form-bio {
|
|
padding: 10px;
|
|
border: 1px solid var(--primary-low);
|
|
}
|
|
|
|
.d-editor-preview img {
|
|
padding-bottom: 1.4em;
|
|
&.emoji,
|
|
&.avatar,
|
|
&.onebox-avatar,
|
|
&.site-icon {
|
|
padding-bottom: 0;
|
|
}
|
|
&.resizable {
|
|
object-fit: cover;
|
|
object-position: top;
|
|
}
|
|
}
|
|
|
|
.d-editor-preview .image-wrapper {
|
|
--resizer-height: 1.75em;
|
|
position: relative;
|
|
display: inline-block;
|
|
.desktop-view & {
|
|
// need the extra space on mobile because controls are always visible
|
|
padding-bottom: var(--resizer-height);
|
|
margin-bottom: calc(var(--resizer-height) * -1);
|
|
}
|
|
|
|
img {
|
|
padding-bottom: 0;
|
|
}
|
|
|
|
&:hover {
|
|
.button-wrapper {
|
|
opacity: 1;
|
|
}
|
|
}
|
|
|
|
.button-wrapper {
|
|
min-width: 10em;
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
flex-wrap: nowrap;
|
|
align-items: center;
|
|
gap: 0 0.5em;
|
|
|
|
position: absolute;
|
|
height: calc(var(--resizer-height) + 0.5em);
|
|
bottom: 0;
|
|
left: 0;
|
|
opacity: 0;
|
|
transition: all 0.25s;
|
|
z-index: 1; // needs to be higher than image
|
|
background: var(--secondary); // for when images are wider than controls
|
|
|
|
&[editing] {
|
|
opacity: 1;
|
|
}
|
|
|
|
.scale-btn-container,
|
|
.alt-text-readonly-container,
|
|
.alt-text-edit-container,
|
|
.delete-image-button {
|
|
background: var(--secondary);
|
|
display: flex;
|
|
height: var(--resizer-height);
|
|
align-items: center;
|
|
|
|
&[hidden] {
|
|
display: none;
|
|
}
|
|
}
|
|
|
|
.scale-btn {
|
|
color: var(--tertiary);
|
|
padding: 0 1em;
|
|
|
|
&:first-child,
|
|
&:last-child {
|
|
padding: 0;
|
|
}
|
|
|
|
&.active {
|
|
font-weight: bold;
|
|
color: var(--primary);
|
|
}
|
|
|
|
&:not(.active):hover {
|
|
text-decoration: underline;
|
|
cursor: pointer;
|
|
}
|
|
}
|
|
|
|
.alt-text-readonly-container {
|
|
flex: 1 1 auto;
|
|
// arbitrary min-width value allows for correct shrinking
|
|
min-width: 100px;
|
|
|
|
.alt-text {
|
|
margin-right: 0.5em;
|
|
overflow: hidden;
|
|
white-space: nowrap;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.alt-text-edit-btn {
|
|
cursor: pointer;
|
|
color: var(--tertiary);
|
|
|
|
svg {
|
|
padding-right: 0.5em;
|
|
}
|
|
}
|
|
}
|
|
|
|
.alt-text-edit-container {
|
|
gap: 0 0.25em;
|
|
flex: 1;
|
|
max-width: 100%;
|
|
|
|
.alt-text-input,
|
|
.alt-text-edit-ok,
|
|
.alt-text-edit-cancel {
|
|
height: var(--resizer-height);
|
|
}
|
|
|
|
.alt-text-input {
|
|
display: inline-flex;
|
|
flex: 1;
|
|
overflow: hidden;
|
|
white-space: nowrap;
|
|
text-overflow: ellipsis;
|
|
margin: 0;
|
|
padding-left: 0.25em;
|
|
}
|
|
|
|
.alt-text-edit-ok,
|
|
.alt-text-edit-cancel {
|
|
border: none;
|
|
width: var(--resizer-height);
|
|
|
|
svg {
|
|
margin: 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
.delete-image-button {
|
|
cursor: pointer;
|
|
color: var(--danger);
|
|
|
|
.d-icon-trash-alt {
|
|
margin-left: 0.5em;
|
|
}
|
|
}
|
|
|
|
.wrap-image-grid-button {
|
|
cursor: pointer;
|
|
color: var(--tertiary);
|
|
}
|
|
|
|
svg {
|
|
pointer-events: none;
|
|
}
|
|
}
|
|
}
|
|
|
|
.mobile-view .d-editor-preview .image-wrapper .button-wrapper {
|
|
opacity: 1;
|
|
}
|
|
|
|
// d-editor bar button sizing
|
|
.d-editor-button-bar {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(2.35em, 1fr));
|
|
@include breakpoint(tablet) {
|
|
// occupy available space on narrower screens
|
|
grid-template-columns: repeat(auto-fit, minmax(2em, 1fr));
|
|
}
|
|
@include breakpoint(mobile-medium) {
|
|
font-size: var(--font-down-1);
|
|
}
|
|
align-items: center;
|
|
border-bottom: 1px solid var(--primary-low);
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
flex-shrink: 0;
|
|
|
|
.btn:focus {
|
|
@include default-focus;
|
|
}
|
|
|
|
.btn {
|
|
margin: 0;
|
|
background-color: transparent;
|
|
color: var(--primary-medium);
|
|
|
|
.d-icon {
|
|
color: currentColor;
|
|
}
|
|
.discourse-no-touch & {
|
|
&:hover {
|
|
color: var(--primary-low);
|
|
}
|
|
}
|
|
}
|
|
|
|
.select-kit-header-wrapper {
|
|
justify-content: center;
|
|
}
|
|
}
|
|
|
|
.d-editor #form-template-form {
|
|
overflow: auto;
|
|
background: var(--primary-very-low);
|
|
padding: 1rem;
|
|
border: 1px solid var(--primary-medium);
|
|
}
|