Merge branch 'main' into custom-ui-more-tools

pull/3075/head
Kesavaraja Krishnan 2024-03-07 20:26:31 +05:30 zatwierdzone przez GitHub
commit 55b7cf52c6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 11 dodań i 9 usunięć

Wyświetl plik

@ -50,6 +50,17 @@ export function useUrlState(onChangeUrl: (params: UrlStateParams) => void) {
const url = new URL(location.href)
// We need to check the page first so that any changes to the camera will be applied to the correct page.
if (url.searchParams.has(PARAMS.page) || url.searchParams.has(PARAMS.p)) {
const newPageId =
url.searchParams.get(PARAMS.page) ?? 'page:' + url.searchParams.get(PARAMS.p)
if (newPageId) {
if (editor.store.has(newPageId as TLPageId)) {
editor.setCurrentPage(newPageId as TLPageId)
}
}
}
if (url.searchParams.has(PARAMS.viewport) || url.searchParams.has(PARAMS.v)) {
const newViewportRaw = url.searchParams.get(PARAMS.viewport) ?? url.searchParams.get(PARAMS.v)
if (newViewportRaw) {
@ -70,15 +81,6 @@ export function useUrlState(onChangeUrl: (params: UrlStateParams) => void) {
}
}
}
if (url.searchParams.has(PARAMS.page) || url.searchParams.has(PARAMS.p)) {
const newPageId =
url.searchParams.get(PARAMS.page) ?? 'page:' + url.searchParams.get(PARAMS.p)
if (newPageId) {
if (editor.store.has(newPageId as TLPageId)) {
editor.setCurrentPage(newPageId as TLPageId)
}
}
}
const handleChange = debounce((params: UrlStateParams | null) => {
if (params) onChangeUrlRef.current(params)