mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 17:11:17 -08:00
feat: reorderable composer trigger buttons (#1261)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description Allow customization of trigger button in the input bar as we slimmed it down Fixes #1236 #### 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: - [ ] 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. -->
This commit is contained in:
5 files changed
+303
-23
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
Add toggleable, reorderable composer trigger buttons (emoji, gif, sticker) with a drag-and-drop settings list.
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
DevicesIcon,
|
||||
DotsThreeIcon,
|
||||
DotsThreeOutlineVerticalIcon,
|
||||
DotsSixVerticalIcon,
|
||||
DownloadIcon,
|
||||
EnvelopeSimpleIcon,
|
||||
EyeIcon,
|
||||
@@ -45,6 +46,7 @@ import {
|
||||
FlowerIcon,
|
||||
FunnelIcon,
|
||||
GearSixIcon,
|
||||
GifIcon,
|
||||
GlobeIcon,
|
||||
GridFourIcon,
|
||||
HardDrivesIcon,
|
||||
@@ -342,6 +344,7 @@ export {
|
||||
DevicesIcon as Devices,
|
||||
DotsThreeIcon as DotsThree,
|
||||
DotsThreeOutlineVerticalIcon,
|
||||
DotsSixVerticalIcon,
|
||||
DownloadIcon as Download,
|
||||
EnvelopeSimpleIcon as EnvelopeSimple,
|
||||
EyeIcon as Eye,
|
||||
@@ -352,6 +355,7 @@ export {
|
||||
FlowerIcon as Flower,
|
||||
FunnelIcon as Funnel,
|
||||
GearSixIcon as GearSix,
|
||||
GifIcon as Gif,
|
||||
GlobeIcon as Globe,
|
||||
GridFourIcon as GridFour,
|
||||
HardDrivesIcon as HardDrives,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { KeyboardEventHandler, MouseEvent, RefObject } from 'react';
|
||||
import { forwardRef, useCallback, useEffect, useRef, useState, useMemo } from 'react';
|
||||
import { forwardRef, Fragment, useCallback, useEffect, useRef, useState, useMemo } from 'react';
|
||||
import type { ReactElement } from 'react';
|
||||
import { useAtom, useAtomValue, useSetAtom } from 'jotai';
|
||||
|
||||
import { isKeyHotkey } from 'is-hotkey';
|
||||
@@ -145,6 +146,7 @@ import {
|
||||
composerIcon,
|
||||
dropzoneIcon,
|
||||
File as FileIcon,
|
||||
Gif,
|
||||
Image as ImageIcon,
|
||||
ListBullets,
|
||||
MapPinPlusIcon,
|
||||
@@ -154,6 +156,7 @@ import {
|
||||
getPhosphorIconSize,
|
||||
PlusCircle,
|
||||
Smiley,
|
||||
Sticker,
|
||||
Stop,
|
||||
X,
|
||||
} from '$components/icons/phosphor';
|
||||
@@ -297,6 +300,11 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const [enterForNewline] = useSetting(settingsAtom, 'enterForNewline');
|
||||
const [editorOldAddFile] = useSetting(settingsAtom, 'editorOldAddFile');
|
||||
const [editorGifButton] = useSetting(settingsAtom, 'editorGifButton');
|
||||
const [editorEmojiButton] = useSetting(settingsAtom, 'editorEmojiButton');
|
||||
const [editorStickerButton] = useSetting(settingsAtom, 'editorStickerButton');
|
||||
const [editorMicButton] = useSetting(settingsAtom, 'editorMicButton');
|
||||
const [editorButtonOrder] = useSetting(settingsAtom, 'editorButtonOrder');
|
||||
const [shortcutOverrides] = useSetting(settingsAtom, 'shortcutOverrides');
|
||||
|
||||
const [hideActivity] = useSetting(settingsAtom, 'hideActivity');
|
||||
@@ -1878,22 +1886,69 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
/>
|
||||
);
|
||||
const triggers = (
|
||||
<IconButton
|
||||
ref={emojiBtnRef}
|
||||
aria-pressed={emojiBoardTab !== undefined}
|
||||
onClick={() => setEmojiBoardTab(EmojiBoardTab.Emoji)}
|
||||
onPointerDown={suppressEditorRefocus}
|
||||
variant="SurfaceVariant"
|
||||
size="300"
|
||||
radii="300"
|
||||
style={{ backgroundColor: 'transparent' }}
|
||||
title="open emoji board"
|
||||
aria-label="Open emoji board"
|
||||
>
|
||||
{composerIcon(Smiley, {
|
||||
weight: emojiBoardTab !== undefined ? 'fill' : 'regular',
|
||||
<>
|
||||
{editorButtonOrder.map((id) => {
|
||||
let button: ReactElement | null = null;
|
||||
if (id === 'gif' && editorGifButton) {
|
||||
button = (
|
||||
<IconButton
|
||||
aria-pressed={emojiBoardTab === EmojiBoardTab.Gif}
|
||||
onClick={() => setEmojiBoardTab(EmojiBoardTab.Gif)}
|
||||
onPointerDown={suppressEditorRefocus}
|
||||
variant="SurfaceVariant"
|
||||
size="300"
|
||||
radii="300"
|
||||
style={{ backgroundColor: 'transparent' }}
|
||||
title="open gif picker"
|
||||
aria-label="Open gif picker"
|
||||
>
|
||||
{composerIcon(Gif, {
|
||||
weight: emojiBoardTab === EmojiBoardTab.Gif ? 'fill' : 'regular',
|
||||
})}
|
||||
</IconButton>
|
||||
);
|
||||
} else if (id === 'sticker' && editorStickerButton) {
|
||||
button = (
|
||||
<IconButton
|
||||
aria-pressed={emojiBoardTab === EmojiBoardTab.Sticker}
|
||||
onClick={() => setEmojiBoardTab(EmojiBoardTab.Sticker)}
|
||||
onPointerDown={suppressEditorRefocus}
|
||||
variant="SurfaceVariant"
|
||||
size="300"
|
||||
radii="300"
|
||||
style={{ backgroundColor: 'transparent' }}
|
||||
title="open sticker picker"
|
||||
aria-label="Open sticker picker"
|
||||
>
|
||||
{composerIcon(Sticker, {
|
||||
weight:
|
||||
emojiBoardTab === EmojiBoardTab.Sticker ? 'fill' : 'regular',
|
||||
})}
|
||||
</IconButton>
|
||||
);
|
||||
} else if (id === 'emoji' && editorEmojiButton) {
|
||||
button = (
|
||||
<IconButton
|
||||
ref={emojiBtnRef}
|
||||
aria-pressed={emojiBoardTab !== undefined}
|
||||
onClick={() => setEmojiBoardTab(EmojiBoardTab.Emoji)}
|
||||
onPointerDown={suppressEditorRefocus}
|
||||
variant="SurfaceVariant"
|
||||
size="300"
|
||||
radii="300"
|
||||
style={{ backgroundColor: 'transparent' }}
|
||||
title="open emoji board"
|
||||
aria-label="Open emoji board"
|
||||
>
|
||||
{composerIcon(Smiley, {
|
||||
weight: emojiBoardTab !== undefined ? 'fill' : 'regular',
|
||||
})}
|
||||
</IconButton>
|
||||
);
|
||||
}
|
||||
return <Fragment key={id}>{button}</Fragment>;
|
||||
})}
|
||||
</IconButton>
|
||||
</>
|
||||
);
|
||||
if (mobileOrTablet()) {
|
||||
return (
|
||||
@@ -1943,23 +1998,23 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
showAudioRecorder ? 'Critical' : scheduledTime ? 'Primary' : 'SurfaceVariant'
|
||||
}
|
||||
size="300"
|
||||
radii={hasContent || showAudioRecorder ? '0' : '300'}
|
||||
radii={hasContent || showAudioRecorder || !editorMicButton ? '0' : '300'}
|
||||
title={
|
||||
showAudioRecorder
|
||||
? 'Stop recording'
|
||||
: hasContent
|
||||
: hasContent || !editorMicButton
|
||||
? 'Send Message'
|
||||
: 'Record audio message'
|
||||
}
|
||||
aria-label={
|
||||
showAudioRecorder
|
||||
? 'Stop recording'
|
||||
: hasContent
|
||||
: hasContent || !editorMicButton
|
||||
? 'Send your composed Message'
|
||||
: 'Record audio message'
|
||||
}
|
||||
style={{ backgroundColor: 'transparent' }}
|
||||
aria-pressed={!hasContent ? showAudioRecorder : undefined}
|
||||
aria-pressed={!hasContent && editorMicButton ? showAudioRecorder : undefined}
|
||||
onClick={() => {
|
||||
if (showAudioRecorder) {
|
||||
audioRecorderRef.current?.stop();
|
||||
@@ -1973,6 +2028,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
submit();
|
||||
return;
|
||||
}
|
||||
if (!editorMicButton) return;
|
||||
if (mobileOrTablet()) return;
|
||||
setShowAudioRecorder(true);
|
||||
}}
|
||||
@@ -1991,6 +2047,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!editorMicButton) return;
|
||||
if (!mobileOrTablet()) return;
|
||||
micHoldStartRef.current = Date.now();
|
||||
setShowAudioRecorder(true);
|
||||
@@ -2042,7 +2099,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
weight="fill"
|
||||
style={{ color: color.Critical.Main }}
|
||||
/>
|
||||
) : hasContent ? (
|
||||
) : hasContent || !editorMicButton ? (
|
||||
sendBusy ? (
|
||||
<Spinner size="300" variant="Secondary" />
|
||||
) : scheduledTime ? (
|
||||
|
||||
@@ -4,13 +4,14 @@ import type {
|
||||
KeyboardEventHandler,
|
||||
MouseEventHandler,
|
||||
} from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import dayjs from 'dayjs';
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import type { RectCords } from 'folds';
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
color,
|
||||
config,
|
||||
Header,
|
||||
IconButton,
|
||||
@@ -27,17 +28,25 @@ import {
|
||||
ArrowUp,
|
||||
CaretDown,
|
||||
composerIcon,
|
||||
DotsSixVerticalIcon,
|
||||
Download,
|
||||
Gif,
|
||||
Info,
|
||||
menuIcon,
|
||||
Shield,
|
||||
Smiley,
|
||||
Sticker,
|
||||
X,
|
||||
} from '$components/icons/phosphor';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import {
|
||||
draggable,
|
||||
dropTargetForElements,
|
||||
} from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
||||
import { PageContent } from '$components/page';
|
||||
import { SequenceCard } from '$components/sequence-card';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import type { DateFormat, MessageSpacing, CaptionPosition } from '$state/settings';
|
||||
import type { DateFormat, EditorButtonId, MessageSpacing, CaptionPosition } from '$state/settings';
|
||||
import { MessageLayout, RightSwipeAction, settingsAtom } from '$state/settings';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
import { KeySymbol } from '$utils/key-symbol';
|
||||
@@ -418,10 +427,105 @@ function DateAndTime() {
|
||||
);
|
||||
}
|
||||
|
||||
const EDITOR_BUTTON_META = {
|
||||
gif: { name: 'Gif', Icon: Gif },
|
||||
sticker: { name: 'Sticker', Icon: Sticker },
|
||||
emoji: { name: 'Emoji', Icon: Smiley },
|
||||
};
|
||||
|
||||
type EditorButtonOrderRowProps = {
|
||||
id: EditorButtonId;
|
||||
index: number;
|
||||
isDragging: boolean;
|
||||
onDraggingIndexChange: (index: number | null) => void;
|
||||
onReorder: (from: number, to: number) => void;
|
||||
};
|
||||
|
||||
function EditorButtonOrderRow({
|
||||
id,
|
||||
index,
|
||||
isDragging,
|
||||
onDraggingIndexChange,
|
||||
onReorder,
|
||||
}: Readonly<EditorButtonOrderRowProps>) {
|
||||
const rowRef = useRef<HTMLDivElement>(null);
|
||||
const { name, Icon } = EDITOR_BUTTON_META[id];
|
||||
|
||||
useEffect(() => {
|
||||
const element = rowRef.current;
|
||||
if (!element) return undefined;
|
||||
return draggable({
|
||||
element,
|
||||
getInitialData: () => ({ index }),
|
||||
onDragStart: () => onDraggingIndexChange(index),
|
||||
onDrop: () => onDraggingIndexChange(null),
|
||||
});
|
||||
}, [index, onDraggingIndexChange]);
|
||||
|
||||
useEffect(() => {
|
||||
const element = rowRef.current;
|
||||
if (!element) return undefined;
|
||||
return dropTargetForElements({
|
||||
element,
|
||||
getData: () => ({ index }),
|
||||
onDrop: ({ source }) => {
|
||||
const from = source.data.index;
|
||||
if (typeof from !== 'number' || from === index) return;
|
||||
onReorder(from, index);
|
||||
},
|
||||
});
|
||||
}, [index, onReorder]);
|
||||
|
||||
return (
|
||||
<SequenceCard
|
||||
ref={rowRef}
|
||||
className={SequenceCardStyle}
|
||||
variant="Surface"
|
||||
direction="Column"
|
||||
style={{ opacity: isDragging ? 0.4 : 1, cursor: 'grab' }}
|
||||
>
|
||||
<SettingTile
|
||||
focusId={`editor-button-order-${id}`}
|
||||
title={name}
|
||||
before={composerIcon(Icon, { weight: 'regular' })}
|
||||
after={composerIcon(DotsSixVerticalIcon)}
|
||||
/>
|
||||
</SequenceCard>
|
||||
);
|
||||
}
|
||||
|
||||
function Editor() {
|
||||
const [enterForNewline, setEnterForNewline] = useSetting(settingsAtom, 'enterForNewline');
|
||||
const [editorToolbar, setEditorToolbar] = useSetting(settingsAtom, 'editorToolbar');
|
||||
const [editorOldAddFile, setEditorOldAddFile] = useSetting(settingsAtom, 'editorOldAddFile');
|
||||
const [editorMicButton, setEditorMicButton] = useSetting(settingsAtom, 'editorMicButton');
|
||||
const [editorEmojiButton, setEditorEmojiButton] = useSetting(settingsAtom, 'editorEmojiButton');
|
||||
const [editorGifButton, setEditorGifButton] = useSetting(settingsAtom, 'editorGifButton');
|
||||
const [editorStickerButton, setEditorStickerButton] = useSetting(
|
||||
settingsAtom,
|
||||
'editorStickerButton'
|
||||
);
|
||||
const [editorButtonOrder, setEditorButtonOrder] = useSetting(settingsAtom, 'editorButtonOrder');
|
||||
const [draggingIndex, setDraggingIndex] = useState<number | null>(null);
|
||||
|
||||
const handleReorder = useCallback(
|
||||
(from: number, to: number) => {
|
||||
if (from === to) return;
|
||||
setEditorButtonOrder((prev) => {
|
||||
const next = [...prev];
|
||||
const removed = next.splice(from, 1);
|
||||
next.splice(to, 0, ...removed);
|
||||
return next;
|
||||
});
|
||||
},
|
||||
[setEditorButtonOrder]
|
||||
);
|
||||
const enabledButtons: Record<EditorButtonId, boolean> = {
|
||||
gif: editorGifButton,
|
||||
sticker: editorStickerButton,
|
||||
emoji: editorEmojiButton,
|
||||
};
|
||||
const hasEnabledOrder = editorButtonOrder.some((id) => enabledButtons[id]);
|
||||
const [hideActivity, setHideActivity] = useSetting(settingsAtom, 'hideActivity');
|
||||
const [hideReads, setHideReads] = useSetting(settingsAtom, 'hideReads');
|
||||
const [sendPresence, setSendPresence] = useSetting(settingsAtom, 'sendPresence');
|
||||
@@ -460,6 +564,78 @@ function Editor() {
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Show Voice Recording Button"
|
||||
focusId="show-voice-recording-button"
|
||||
description="Show the microphone button in the message composer. When off, the send button shows even when the editor is empty."
|
||||
after={<Switch variant="Primary" value={editorMicButton} onChange={setEditorMicButton} />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Show Emoji Button"
|
||||
focusId="show-emoji-button"
|
||||
description="Show the emoji button inline with the message composer."
|
||||
after={
|
||||
<Switch variant="Primary" value={editorEmojiButton} onChange={setEditorEmojiButton} />
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Show Gif Button"
|
||||
focusId="show-gif-button"
|
||||
description="Show the gif button inline with the message composer. This makes requests to klipy.com whenever you search for a gif."
|
||||
after={<Switch variant="Primary" value={editorGifButton} onChange={setEditorGifButton} />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Show Sticker Button"
|
||||
focusId="show-sticker-button"
|
||||
description="Show the sticker button inline with the message composer."
|
||||
after={
|
||||
<Switch
|
||||
variant="Primary"
|
||||
value={editorStickerButton}
|
||||
onChange={setEditorStickerButton}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Composer Button Order"
|
||||
focusId="composer-button-order"
|
||||
description="Drag to reorder the buttons shown in the message composer. Use the show/hide toggles above to control which buttons appear."
|
||||
/>
|
||||
{hasEnabledOrder && (
|
||||
<Box
|
||||
direction="Column"
|
||||
gap="200"
|
||||
style={{
|
||||
backgroundColor: color.Background.Container,
|
||||
borderRadius: config.radii.R400,
|
||||
marginInline: config.space.S300,
|
||||
marginTop: config.space.S300,
|
||||
}}
|
||||
>
|
||||
{editorButtonOrder.map((id, index) =>
|
||||
enabledButtons[id] ? (
|
||||
<EditorButtonOrderRow
|
||||
key={id}
|
||||
id={id}
|
||||
index={index}
|
||||
isDragging={draggingIndex === index}
|
||||
onDraggingIndexChange={setDraggingIndex}
|
||||
onReorder={handleReorder}
|
||||
/>
|
||||
) : null
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Hide Typing Indicators"
|
||||
|
||||
@@ -42,6 +42,11 @@ export type PerRoomShowRoomIcon = {
|
||||
};
|
||||
|
||||
export type JumboEmojiSize = 'none' | 'extraSmall' | 'small' | 'normal' | 'large' | 'extraLarge';
|
||||
|
||||
/** Reorderable inline trigger buttons in the message composer. */
|
||||
export type EditorButtonId = 'gif' | 'sticker' | 'emoji';
|
||||
export const EDITOR_BUTTON_ORDER_DEFAULT: EditorButtonId[] = ['gif', 'sticker', 'emoji'];
|
||||
const EDITOR_BUTTON_ORDER_VALUES = new Set<EditorButtonId>(EDITOR_BUTTON_ORDER_DEFAULT);
|
||||
export const CALL_TONE_IDS = [
|
||||
'sable-default',
|
||||
'classic-soft',
|
||||
@@ -116,6 +121,11 @@ export interface Settings {
|
||||
enterForNewline: boolean;
|
||||
editorToolbar: boolean;
|
||||
editorOldAddFile: boolean;
|
||||
editorMicButton: boolean;
|
||||
editorEmojiButton: boolean;
|
||||
editorGifButton: boolean;
|
||||
editorStickerButton: boolean;
|
||||
editorButtonOrder: EditorButtonId[];
|
||||
composerToolbarOpen: boolean;
|
||||
messageLayout: MessageLayout;
|
||||
messageSpacing: MessageSpacing;
|
||||
@@ -289,6 +299,11 @@ export const defaultSettings: Settings = {
|
||||
enterForNewline: mobileOrTablet(),
|
||||
editorToolbar: false,
|
||||
editorOldAddFile: false,
|
||||
editorMicButton: true,
|
||||
editorEmojiButton: true,
|
||||
editorGifButton: false,
|
||||
editorStickerButton: false,
|
||||
editorButtonOrder: [...EDITOR_BUTTON_ORDER_DEFAULT],
|
||||
composerToolbarOpen: false,
|
||||
messageLayout: 0,
|
||||
messageSpacing: '400',
|
||||
@@ -449,6 +464,7 @@ function cloneDefaultSettings(): Settings {
|
||||
})),
|
||||
themeRemoteTweakFavorites: defaultSettings.themeRemoteTweakFavorites.map((x) => ({ ...x })),
|
||||
themeRemoteEnabledTweakFullUrls: [...defaultSettings.themeRemoteEnabledTweakFullUrls],
|
||||
editorButtonOrder: [...defaultSettings.editorButtonOrder],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -568,6 +584,26 @@ function sanitizeStringArray(val: unknown): string[] | undefined {
|
||||
return out;
|
||||
}
|
||||
|
||||
function sanitizeEditorButtonOrder(val: unknown): EditorButtonId[] | undefined {
|
||||
if (!Array.isArray(val)) return undefined;
|
||||
const out: EditorButtonId[] = [];
|
||||
const seen = new Set<EditorButtonId>();
|
||||
for (const x of val) {
|
||||
if (typeof x === 'string' && EDITOR_BUTTON_ORDER_VALUES.has(x as EditorButtonId)) {
|
||||
const id = x as EditorButtonId;
|
||||
if (!seen.has(id)) {
|
||||
seen.add(id);
|
||||
out.push(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Append any missing buttons in default order so the array is always complete.
|
||||
for (const id of EDITOR_BUTTON_ORDER_DEFAULT) {
|
||||
if (!seen.has(id)) out.push(id);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function sanitizeThemeRemoteFavorites(val: unknown): ThemeRemoteFavorite[] | undefined {
|
||||
if (!Array.isArray(val)) return undefined;
|
||||
const out: ThemeRemoteFavorite[] = [];
|
||||
@@ -688,6 +724,8 @@ function sanitizeSettingsKey(key: keyof Settings, val: unknown): unknown {
|
||||
return sanitizeThemeRemoteTweakFavorites(val);
|
||||
case 'themeRemoteEnabledTweakFullUrls':
|
||||
return sanitizeStringArray(val);
|
||||
case 'editorButtonOrder':
|
||||
return sanitizeEditorButtonOrder(val);
|
||||
default: {
|
||||
if (!(key in defaultSettings)) return undefined;
|
||||
const sample = defaultSettings[key];
|
||||
|
||||
Reference in new issue
Block a user