[fix] exit penmode (#1847)

This PR fixes the "Exit Pen Mode" button (see first commit).

There are some other "wrap some stuff in editor.batch" changes in the
"follow up changes" commit.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Use an ipad / pencil to enter pen mode
2. Click the Exit pen mode button
This commit is contained in:
Steve Ruiz 2023-09-07 09:09:09 +01:00 committed by GitHub
parent 2e4f1de944
commit cf00eade9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -273,6 +273,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
label: 'action.convert-to-bookmark', label: 'action.convert-to-bookmark',
readonlyOk: false, readonlyOk: false,
onSelect(source) { onSelect(source) {
editor.batch(() => {
trackEvent('convert-to-bookmark', { source }) trackEvent('convert-to-bookmark', { source })
const shapes = editor.selectedShapes const shapes = editor.selectedShapes
@ -305,6 +306,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
editor.mark('convert shapes to bookmark') editor.mark('convert shapes to bookmark')
editor.deleteShapes(deleteList) editor.deleteShapes(deleteList)
editor.createShapes(createList) editor.createShapes(createList)
})
}, },
}, },
{ {
@ -313,6 +315,8 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
readonlyOk: false, readonlyOk: false,
onSelect(source) { onSelect(source) {
trackEvent('convert-to-embed', { source }) trackEvent('convert-to-embed', { source })
editor.batch(() => {
const ids = editor.selectedShapeIds const ids = editor.selectedShapeIds
const shapes = compact(ids.map((id) => editor.getShape(id))) const shapes = compact(ids.map((id) => editor.getShape(id)))
@ -355,6 +359,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
editor.mark('convert shapes to embed') editor.mark('convert shapes to embed')
editor.deleteShapes(deleteList) editor.deleteShapes(deleteList)
editor.createShapes(createList) editor.createShapes(createList)
})
}, },
}, },
{ {
@ -682,6 +687,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
kbd: '$a', kbd: '$a',
readonlyOk: true, readonlyOk: true,
onSelect(source) { onSelect(source) {
editor.batch(() => {
trackEvent('select-all-shapes', { source }) trackEvent('select-all-shapes', { source })
if (editor.currentToolId !== 'select') { if (editor.currentToolId !== 'select') {
editor.cancel() editor.cancel()
@ -690,6 +696,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
editor.mark('select all kbd') editor.mark('select all kbd')
editor.selectAll() editor.selectAll()
})
}, },
}, },
{ {
@ -915,12 +922,9 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
readonlyOk: true, readonlyOk: true,
onSelect(source) { onSelect(source) {
trackEvent('toggle-debug-mode', { source }) trackEvent('toggle-debug-mode', { source })
editor.updateInstanceState( editor.updateInstanceState({
{
isDebugMode: !editor.instanceState.isDebugMode, isDebugMode: !editor.instanceState.isDebugMode,
}, })
{ ephemeral: true }
)
}, },
checkbox: true, checkbox: true,
}, },
@ -941,7 +945,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
readonlyOk: true, readonlyOk: true,
onSelect(source) { onSelect(source) {
trackEvent('exit-pen-mode', { source }) trackEvent('exit-pen-mode', { source })
editor.instanceState.isPenMode = false editor.updateInstanceState({ isPenMode: false })
}, },
}, },
{ {