mirror of
https://github.com/SableClient/Sable.git
synced 2026-12-03 07:12:34 -08:00
feat: add always inline editor option for multiline messages (#1218)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description <!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Fixes #1181 Add an option to force the text editor to stay inline with the buttons. See the corresponding issue. Keep current editor style as default, as it's unique. This changes the alignment of the items in the text editor row to "end" for the classic editor too. This does not change behavior. #### Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings ### AI disclosure: - [x] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. --> I used Opus 4.8 for generating the settings boilerplate. I manually reviewed and edited all generated output.
This commit is contained in:
6 files changed
+31
-3
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Add option to always keep the last line of the text editor "inline" with the UI buttons.
|
||||
@@ -15,7 +15,7 @@ export const Editor = style([
|
||||
|
||||
export const EditorRow = style({
|
||||
gridTemplateColumns: 'auto 1fr auto',
|
||||
alignItems: 'center',
|
||||
alignItems: 'end',
|
||||
});
|
||||
|
||||
export const EditorRowMultiline = style({
|
||||
@@ -80,6 +80,10 @@ export const EditorTextarea = style([
|
||||
},
|
||||
]);
|
||||
|
||||
export const EditorTextareaInline = style({
|
||||
paddingBottom: toRem(13),
|
||||
});
|
||||
|
||||
export const EditorResponsiveAfterMultiline = style([
|
||||
EditorOptions,
|
||||
{
|
||||
|
||||
@@ -146,7 +146,8 @@ export const CustomEditor = forwardRef<HTMLDivElement, CustomEditorProps>(
|
||||
const hasBefore = Boolean(before);
|
||||
const hasAfter = Boolean(after);
|
||||
const hasResponsiveAfter = Boolean(responsiveAfter);
|
||||
const layoutIsMultiline = isMultiline || forceMultilineLayout;
|
||||
const [alwaysInlineEditor] = useSetting(settingsAtom, 'alwaysInlineEditor');
|
||||
const layoutIsMultiline = !alwaysInlineEditor && (isMultiline || forceMultilineLayout);
|
||||
const showResponsiveAfterInFooter = hasResponsiveAfter && layoutIsMultiline;
|
||||
const showResponsiveAfterInline = hasResponsiveAfter && !showResponsiveAfterInFooter;
|
||||
|
||||
@@ -475,7 +476,7 @@ export const CustomEditor = forwardRef<HTMLDivElement, CustomEditorProps>(
|
||||
<Editable
|
||||
ref={editableRef}
|
||||
data-editable-name={editableName}
|
||||
className={css.EditorTextarea}
|
||||
className={`${css.EditorTextarea} ${alwaysInlineEditor ? css.EditorTextareaInline : ''}`}
|
||||
placeholder={placeholder}
|
||||
renderPlaceholder={renderPlaceholder}
|
||||
renderElement={renderElement}
|
||||
|
||||
@@ -367,6 +367,11 @@ function LottieImage({
|
||||
<DotLottieReact
|
||||
{...props}
|
||||
data={data}
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
...(emoticon ? { width: '1em', height: '1em' } : undefined),
|
||||
}}
|
||||
aria-label={props['aria-label'] ?? alt}
|
||||
backgroundColor="#00000000"
|
||||
dotLottieRefCallback={setPlayer}
|
||||
|
||||
@@ -440,6 +440,10 @@ function EditorButtonOrderRow({
|
||||
function Editor() {
|
||||
const [enterForNewline, setEnterForNewline] = useSetting(settingsAtom, 'enterForNewline');
|
||||
const [editorToolbar, setEditorToolbar] = useSetting(settingsAtom, 'editorToolbar');
|
||||
const [alwaysInlineEditor, setAlwaysInlineEditor] = useSetting(
|
||||
settingsAtom,
|
||||
'alwaysInlineEditor'
|
||||
);
|
||||
const [editorOldAddFile, setEditorOldAddFile] = useSetting(settingsAtom, 'editorOldAddFile');
|
||||
const [editorMicButton, setEditorMicButton] = useSetting(settingsAtom, 'editorMicButton');
|
||||
const [editorEmojiButton, setEditorEmojiButton] = useSetting(settingsAtom, 'editorEmojiButton');
|
||||
@@ -530,6 +534,13 @@ function Editor() {
|
||||
value={editorStickerButton}
|
||||
onChange={setEditorStickerButton}
|
||||
/>
|
||||
<SettingToggle
|
||||
title="Always Inline Editor"
|
||||
focusId="always-inline-editor"
|
||||
description="Always keep the last line of the text editor inline with UI buttons."
|
||||
value={alwaysInlineEditor}
|
||||
onChange={setAlwaysInlineEditor}
|
||||
/>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Composer Button Order"
|
||||
|
||||
@@ -131,6 +131,7 @@ export interface Settings {
|
||||
editorStickerButton: boolean;
|
||||
editorButtonOrder: EditorButtonId[];
|
||||
composerToolbarOpen: boolean;
|
||||
alwaysInlineEditor: boolean;
|
||||
messageLayout: MessageLayout;
|
||||
messageSpacing: MessageSpacing;
|
||||
hideMembershipEvents: boolean;
|
||||
@@ -308,6 +309,7 @@ export const defaultSettings: Settings = {
|
||||
editorStickerButton: false,
|
||||
editorButtonOrder: [...EDITOR_BUTTON_ORDER_DEFAULT],
|
||||
composerToolbarOpen: false,
|
||||
alwaysInlineEditor: false,
|
||||
messageLayout: 0,
|
||||
messageSpacing: '400',
|
||||
hideMembershipEvents: false,
|
||||
|
||||
Reference in new issue
Block a user