Fix viewport params for pages. (#3079)
This commit is contained in:
parent
40aeebab46
commit
40c20e5585
1 changed files with 11 additions and 9 deletions
|
@ -50,6 +50,17 @@ export function useUrlState(onChangeUrl: (params: UrlStateParams) => void) {
|
||||||
|
|
||||||
const url = new URL(location.href)
|
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)) {
|
if (url.searchParams.has(PARAMS.viewport) || url.searchParams.has(PARAMS.v)) {
|
||||||
const newViewportRaw = url.searchParams.get(PARAMS.viewport) ?? url.searchParams.get(PARAMS.v)
|
const newViewportRaw = url.searchParams.get(PARAMS.viewport) ?? url.searchParams.get(PARAMS.v)
|
||||||
if (newViewportRaw) {
|
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) => {
|
const handleChange = debounce((params: UrlStateParams | null) => {
|
||||||
if (params) onChangeUrlRef.current(params)
|
if (params) onChangeUrlRef.current(params)
|
||||||
|
|
Loading…
Reference in a new issue