@@ -219,10 +219,20 @@ const initializeScene = async (opts: {
219219 )
220220> => {
221221 const searchParams = new URLSearchParams ( window . location . search ) ;
222+ const hashParams = new URLSearchParams ( window . location . hash . slice ( 1 ) ) ;
222223 const id = searchParams . get ( "id" ) ;
223- const jsonBackendMatch = window . location . hash . match (
224- / ^ # j s o n = ( [ a - z A - Z 0 - 9 _ - ] + ) , ( [ a - z A - Z 0 - 9 _ - ] + ) $ / ,
225- ) ;
224+ const shareableLink = hashParams . get ( "json" ) ?. split ( "," ) ;
225+
226+ if ( shareableLink ) {
227+ hashParams . delete ( "json" ) ;
228+ const hash = `#${ decodeURIComponent ( hashParams . toString ( ) ) } ` ;
229+ window . history . replaceState (
230+ { } ,
231+ APP_NAME ,
232+ `${ window . location . origin } ${ hash } ` ,
233+ ) ;
234+ }
235+
226236 const externalUrlMatch = window . location . hash . match ( / ^ # u r l = ( .* ) $ / ) ;
227237
228238 const localDataState = importFromLocalStorage ( ) ;
@@ -232,7 +242,7 @@ const initializeScene = async (opts: {
232242 } = await loadScene ( null , null , localDataState ) ;
233243
234244 let roomLinkData = getCollaborationLinkData ( window . location . href ) ;
235- const isExternalScene = ! ! ( id || jsonBackendMatch || roomLinkData ) ;
245+ const isExternalScene = ! ! ( id || shareableLink || roomLinkData ) ;
236246 if ( isExternalScene ) {
237247 if (
238248 // don't prompt if scene is empty
@@ -242,16 +252,16 @@ const initializeScene = async (opts: {
242252 // otherwise, prompt whether user wants to override current scene
243253 ( await openConfirmModal ( shareableLinkConfirmDialog ) )
244254 ) {
245- if ( jsonBackendMatch ) {
255+ if ( shareableLink ) {
246256 scene = await loadScene (
247- jsonBackendMatch [ 1 ] ,
248- jsonBackendMatch [ 2 ] ,
257+ shareableLink [ 0 ] ,
258+ shareableLink [ 1 ] ,
249259 localDataState ,
250260 ) ;
251261 }
252262 scene . scrollToContent = true ;
253263 if ( ! roomLinkData ) {
254- window . history . replaceState ( { } , APP_NAME , window . location . origin ) ;
264+ // window.history.replaceState({}, APP_NAME, window.location.origin);
255265 }
256266 } else {
257267 // https://github.com/excalidraw/excalidraw/issues/1919
@@ -268,7 +278,7 @@ const initializeScene = async (opts: {
268278 }
269279
270280 roomLinkData = null ;
271- window . history . replaceState ( { } , APP_NAME , window . location . origin ) ;
281+ // window.history.replaceState({}, APP_NAME, window.location.origin);
272282 }
273283 } else if ( externalUrlMatch ) {
274284 window . history . replaceState ( { } , APP_NAME , window . location . origin ) ;
@@ -329,12 +339,12 @@ const initializeScene = async (opts: {
329339 key : roomLinkData . roomKey ,
330340 } ;
331341 } else if ( scene ) {
332- return isExternalScene && jsonBackendMatch
342+ return isExternalScene && shareableLink
333343 ? {
334344 scene,
335345 isExternalScene,
336- id : jsonBackendMatch [ 1 ] ,
337- key : jsonBackendMatch [ 2 ] ,
346+ id : shareableLink [ 0 ] ,
347+ key : shareableLink [ 1 ] ,
338348 }
339349 : { scene, isExternalScene : false } ;
340350 }
@@ -946,13 +956,20 @@ const ExcalidrawWrapper = () => {
946956 </ div >
947957 ) ;
948958 } }
959+ // scrollConstraints={constraints.enabled ? constraints : undefined}
949960 onLinkOpen = { ( element , event ) => {
950961 if ( element . link && isElementLink ( element . link ) ) {
951962 event . preventDefault ( ) ;
952963 excalidrawAPI ?. scrollToContent ( element . link , { animate : true } ) ;
953964 }
954965 } }
955966 >
967+ { /* {excalidrawAPI && !isTestEnv() && (
968+ <ConstraintsSettings
969+ excalidrawAPI={excalidrawAPI}
970+ initialConstraints={constraints}
971+ />
972+ )} */ }
956973 < AppMainMenu
957974 onCollabDialogOpen = { onCollabDialogOpen }
958975 isCollaborating = { isCollaborating }
0 commit comments