diff --git a/packages/editor/src/lib/editor/Editor.ts b/packages/editor/src/lib/editor/Editor.ts index f3c2bfcf0..5d0fee893 100644 --- a/packages/editor/src/lib/editor/Editor.ts +++ b/packages/editor/src/lib/editor/Editor.ts @@ -1214,7 +1214,7 @@ export class Editor extends EventEmitter { if (partial.isChangingStyle === true) { // If we've set to true, set a new reset timeout to change the value back to false after 2 seconds this._isChangingStyleTimeout = setTimeout(() => { - this.updateInstanceState({ isChangingStyle: false }) + this.updateInstanceState({ isChangingStyle: false }, { ephemeral: true }) }, 2000) } } diff --git a/packages/tldraw/api-report.md b/packages/tldraw/api-report.md index 48b5828d8..d13b26d2a 100644 --- a/packages/tldraw/api-report.md +++ b/packages/tldraw/api-report.md @@ -1927,7 +1927,7 @@ export interface TLUiSliderProps { // (undocumented) label: string; // (undocumented) - onValueChange: (value: number, emphemeral: boolean) => void; + onValueChange: (value: number, squashing: boolean) => void; // (undocumented) steps: number; // (undocumented) diff --git a/packages/tldraw/src/lib/ui/components/MobileStylePanel.tsx b/packages/tldraw/src/lib/ui/components/MobileStylePanel.tsx index bd53018d9..30f34cbde 100644 --- a/packages/tldraw/src/lib/ui/components/MobileStylePanel.tsx +++ b/packages/tldraw/src/lib/ui/components/MobileStylePanel.tsx @@ -37,7 +37,7 @@ export function MobileStylePanel() { const handleStylesOpenChange = useCallback( (isOpen: boolean) => { if (!isOpen) { - editor.updateInstanceState({ isChangingStyle: false }) + editor.updateInstanceState({ isChangingStyle: false }, { ephemeral: true }) } }, [editor] diff --git a/packages/tldraw/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx b/packages/tldraw/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx index 0e1ca9329..4d583ecfe 100644 --- a/packages/tldraw/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +++ b/packages/tldraw/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx @@ -21,7 +21,7 @@ export const DefaultStylePanel = memo(function DefaultStylePanel({ const handlePointerOut = useCallback(() => { if (!isMobile) { - editor.updateInstanceState({ isChangingStyle: false }) + editor.updateInstanceState({ isChangingStyle: false }, { ephemeral: true }) } }, [editor, isMobile]) diff --git a/packages/tldraw/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx b/packages/tldraw/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx index b955e06dc..509670f33 100644 --- a/packages/tldraw/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +++ b/packages/tldraw/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx @@ -76,7 +76,7 @@ function useStyleChangeCallback() { editor.setStyleForSelectedShapes(style, value, { squashing }) } editor.setStyleForNextShapes(style, value, { squashing }) - editor.updateInstanceState({ isChangingStyle: true }) + editor.updateInstanceState({ isChangingStyle: true }, { ephemeral: true }) }) trackEvent('set-style', { source: 'style-panel', id: style.id, value: value as string }) @@ -297,14 +297,14 @@ function OpacitySlider() { const msg = useTranslation() const handleOpacityValueChange = React.useCallback( - (value: number, ephemeral: boolean) => { + (value: number, squashing: boolean) => { const item = tldrawSupportedOpacities[value] editor.batch(() => { if (editor.isIn('select')) { - editor.setOpacityForSelectedShapes(item, { ephemeral }) + editor.setOpacityForSelectedShapes(item, { squashing }) } - editor.setOpacityForNextShapes(item, { ephemeral }) - editor.updateInstanceState({ isChangingStyle: true }) + editor.setOpacityForNextShapes(item, { squashing }) + editor.updateInstanceState({ isChangingStyle: true }, { ephemeral: true }) }) trackEvent('set-style', { source: 'style-panel', id: 'opacity', value }) diff --git a/packages/tldraw/src/lib/ui/components/StylePanel/DropdownPicker.tsx b/packages/tldraw/src/lib/ui/components/StylePanel/DropdownPicker.tsx index 0a47af8ad..675692d55 100644 --- a/packages/tldraw/src/lib/ui/components/StylePanel/DropdownPicker.tsx +++ b/packages/tldraw/src/lib/ui/components/StylePanel/DropdownPicker.tsx @@ -1,4 +1,4 @@ -import { SharedStyle, StyleProp } from '@tldraw/editor' +import { SharedStyle, StyleProp, useEditor } from '@tldraw/editor' import * as React from 'react' import { StyleValuesForUi } from '../../../styles' import { TLUiTranslationKey } from '../../hooks/useTranslation/TLUiTranslationKey' @@ -36,6 +36,7 @@ function _DropdownPicker({ onValueChange, }: DropdownPickerProps) { const msg = useTranslation() + const editor = useEditor() const icon = React.useMemo( () => items.find((item) => value.type === 'shared' && item.value === value.value)?.icon, @@ -65,7 +66,10 @@ function _DropdownPicker({ type="icon" data-testid={`style.${uiType}.${item.value}`} title={msg(`${uiType}-style.${item.value}` as TLUiTranslationKey)} - onClick={() => onValueChange(style, item.value, false)} + onClick={() => { + editor.mark('select style dropdown item') + onValueChange(style, item.value, false) + }} > diff --git a/packages/tldraw/src/lib/ui/components/primitives/TldrawUiSlider.tsx b/packages/tldraw/src/lib/ui/components/primitives/TldrawUiSlider.tsx index e7174e734..94b4079db 100644 --- a/packages/tldraw/src/lib/ui/components/primitives/TldrawUiSlider.tsx +++ b/packages/tldraw/src/lib/ui/components/primitives/TldrawUiSlider.tsx @@ -10,7 +10,7 @@ export interface TLUiSliderProps { value: number | null label: string title: string - onValueChange: (value: number, emphemeral: boolean) => void + onValueChange: (value: number, squashing: boolean) => void 'data-testid'?: string } diff --git a/packages/tldraw/src/lib/ui/hooks/clipboard/pasteTldrawContent.ts b/packages/tldraw/src/lib/ui/hooks/clipboard/pasteTldrawContent.ts index c7f6bb238..80106dd05 100644 --- a/packages/tldraw/src/lib/ui/hooks/clipboard/pasteTldrawContent.ts +++ b/packages/tldraw/src/lib/ui/hooks/clipboard/pasteTldrawContent.ts @@ -24,9 +24,9 @@ export function pasteTldrawContent(editor: Editor, clipboard: TLContent, point?: seletionBoundsBefore?.collides(selectedBoundsAfter) ) { // Creates a 'puff' to show a paste has happened. - editor.updateInstanceState({ isChangingStyle: true }) + editor.updateInstanceState({ isChangingStyle: true }, { ephemeral: true }) setTimeout(() => { - editor.updateInstanceState({ isChangingStyle: false }) + editor.updateInstanceState({ isChangingStyle: false }, { ephemeral: true }) }, 150) } }