Add fill fill style. (#3966)

This PR adds a sneaky action / kbd (Alt-F) for the fill fill style.
Similar to the white action, this is not really documented and may be
removed in the future. But it's cool!!

### Change Type

- [x] `sdk` — Changes the tldraw SDK
- [x] `feature` — New feature

### Test Plan

1. Press Alt-F.

### Release Notes

- Secretly adds a fill-fill style (Alt-F)
This commit is contained in:
Steve Ruiz 2024-06-18 11:50:01 +01:00 committed by GitHub
parent b60ae0f067
commit a307939822
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 21 additions and 2 deletions

View file

@ -136,6 +136,7 @@
"fill-style.semi": "Semi", "fill-style.semi": "Semi",
"fill-style.solid": "Solid", "fill-style.solid": "Solid",
"fill-style.pattern": "Pattern", "fill-style.pattern": "Pattern",
"fill-style.fill": "Fill",
"dash-style.dashed": "Dashed", "dash-style.dashed": "Dashed",
"dash-style.dotted": "Dotted", "dash-style.dotted": "Dotted",
"dash-style.draw": "Draw", "dash-style.draw": "Draw",

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,7 @@
import { import {
Box, Box,
DefaultColorStyle, DefaultColorStyle,
DefaultFillStyle,
Editor, Editor,
HALF_PI, HALF_PI,
PageRecordType, PageRecordType,
@ -1355,11 +1356,26 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
editor.setStyleForSelectedShapes(style, 'white') editor.setStyleForSelectedShapes(style, 'white')
} }
editor.setStyleForNextShapes(style, 'white') editor.setStyleForNextShapes(style, 'white')
editor.updateInstanceState({ isChangingStyle: true })
}) })
trackEvent('set-style', { source, id: style.id, value: 'white' }) trackEvent('set-style', { source, id: style.id, value: 'white' })
}, },
}, },
{
id: 'select-fill-fill',
label: 'fill-style.fill',
kbd: '?f',
onSelect(source) {
const style = DefaultFillStyle
editor.batch(() => {
editor.mark('change-fill')
if (editor.isIn('select')) {
editor.setStyleForSelectedShapes(style, 'fill')
}
editor.setStyleForNextShapes(style, 'fill')
})
trackEvent('set-style', { source, id: style.id, value: 'fill' })
},
},
{ {
id: 'flatten-to-image', id: 'flatten-to-image',
label: 'action.flatten-to-image', label: 'action.flatten-to-image',

View file

@ -140,6 +140,7 @@ export type TLUiTranslationKey =
| 'fill-style.semi' | 'fill-style.semi'
| 'fill-style.solid' | 'fill-style.solid'
| 'fill-style.pattern' | 'fill-style.pattern'
| 'fill-style.fill'
| 'dash-style.dashed' | 'dash-style.dashed'
| 'dash-style.dotted' | 'dash-style.dotted'
| 'dash-style.draw' | 'dash-style.draw'

View file

@ -140,6 +140,7 @@ export const DEFAULT_TRANSLATION = {
'fill-style.semi': 'Semi', 'fill-style.semi': 'Semi',
'fill-style.solid': 'Solid', 'fill-style.solid': 'Solid',
'fill-style.pattern': 'Pattern', 'fill-style.pattern': 'Pattern',
'fill-style.fill': 'Fill',
'dash-style.dashed': 'Dashed', 'dash-style.dashed': 'Dashed',
'dash-style.dotted': 'Dotted', 'dash-style.dotted': 'Dotted',
'dash-style.draw': 'Draw', 'dash-style.draw': 'Draw',