File tree Expand file tree Collapse file tree 2 files changed +11
-33
lines changed
Expand file tree Collapse file tree 2 files changed +11
-33
lines changed Original file line number Diff line number Diff line change @@ -929,29 +929,7 @@ const ExcalidrawWrapper = () => {
929929 </ OverwriteConfirmDialog . Action >
930930 ) }
931931 </ OverwriteConfirmDialog >
932- < AppFooter
933- onChange = { ( ) => excalidrawAPI ?. refresh ( ) }
934- onPresentation = { ( ) => {
935- if ( ! excalidrawAPI ) {
936- return ;
937- }
938- const selectedElementIds =
939- excalidrawAPI . getAppState ( ) . selectedElementIds ;
940- const frames = excalidrawAPI
941- . getSceneElements ( )
942- . filter ( ( e ) => e . type === "frame" ) ;
943- frames . sort ( ( e1 , e2 ) => e1 . y - e2 . y ) ;
944- const framesWithIndex = frames . map ( ( f , index ) => ( { ...f , index } ) ) ;
945- const selectedFrames = framesWithIndex . filter (
946- ( f ) => f . id in selectedElementIds ,
947- ) ;
948- const frameIndex =
949- selectedFrames . length === 0 ? 0 : selectedFrames [ 0 ] . index ;
950- const newUrl = new URL ( window . location . href ) ;
951- newUrl . hash = `#presentation=${ frameIndex } ` ;
952- window . open ( newUrl . href , "_blank" ) ;
953- } }
954- />
932+ < AppFooter onChange = { ( ) => excalidrawAPI ?. refresh ( ) } />
955933 { excalidrawAPI && < AIComponents excalidrawAPI = { excalidrawAPI } /> }
956934
957935 < TTDDialogTrigger />
Original file line number Diff line number Diff line change 11import { Button , Footer } from "@excalidraw/excalidraw/index" ;
2- import React from "react" ;
3-
2+ import React , { useCallback } from "react" ;
43import { useI18n } from "@excalidraw/excalidraw/i18n" ;
4+ import { useExcalidrawActionManager } from "@excalidraw/excalidraw/components/App" ;
5+ import { actionPresent } from "@excalidraw/excalidraw/actions" ;
56
67import { isExcalidrawPlusSignedUser } from "../app_constants" ;
78
@@ -10,14 +11,13 @@ import { EncryptedIcon } from "./EncryptedIcon";
1011import { ExcalidrawPlusAppLink } from "./ExcalidrawPlusAppLink" ;
1112
1213export const AppFooter = React . memo (
13- ( {
14- onChange,
15- onPresentation,
16- } : {
17- onChange : ( ) => void ;
18- onPresentation : ( ) => void ;
19- } ) => {
14+ ( { onChange } : { onChange : ( ) => void } ) => {
2015 const { t } = useI18n ( ) ;
16+ const actionManager = useExcalidrawActionManager ( ) ;
17+ const onPresent = useCallback (
18+ ( ) => actionManager . executeAction ( actionPresent ) ,
19+ [ actionManager ] ,
20+ ) ;
2121
2222 return (
2323 < Footer >
@@ -34,7 +34,7 @@ export const AppFooter = React.memo(
3434 ) : (
3535 < EncryptedIcon />
3636 ) }
37- < Button onSelect = { onPresentation } style = { { width : "fit-content" } } >
37+ < Button onSelect = { onPresent } style = { { width : "fit-content" } } >
3838 { t ( "labels.present" ) }
3939 </ Button >
4040 </ div >
You can’t perform that action at this time.
0 commit comments