mirror of
https://github.com/makeplane/plane.git
synced 2025-12-23 23:29:37 +01:00
* fix: better refactoring of page root and editor body * fix: editor sideeffects * fix: add comments json field * fix: props name * fix: review changes * fix: extra checks * fix: type changes * fix: remove editor ref current * fix: renaming * fix: link check
53 lines
1.9 KiB
TypeScript
53 lines
1.9 KiB
TypeScript
import { useCallback, useMemo, type RefObject } from "react";
|
|
import { useSearchParams } from "next/navigation";
|
|
import type { EditorRefApi } from "@plane/editor";
|
|
import {
|
|
PAGE_NAVIGATION_PANE_TAB_KEYS,
|
|
PAGE_NAVIGATION_PANE_TABS_QUERY_PARAM,
|
|
} from "@/components/pages/navigation-pane";
|
|
import { useAppRouter } from "@/hooks/use-app-router";
|
|
import { useQueryParams } from "@/hooks/use-query-params";
|
|
import type { TPageNavigationPaneTab } from "@/plane-web/components/pages/navigation-pane";
|
|
import { INavigationPaneExtension } from "@/plane-web/types/pages/pane-extensions";
|
|
import type { TPageInstance } from "@/store/pages/base-page";
|
|
|
|
export type TPageExtensionHookParams = {
|
|
page: TPageInstance;
|
|
editorRef: RefObject<EditorRefApi>;
|
|
};
|
|
|
|
export const usePagesPaneExtensions = (_params: TPageExtensionHookParams) => {
|
|
const router = useAppRouter();
|
|
const { updateQueryParams } = useQueryParams();
|
|
const searchParams = useSearchParams();
|
|
|
|
// Generic navigation pane logic - hook manages feature-specific routing
|
|
const navigationPaneQueryParam = searchParams.get(
|
|
PAGE_NAVIGATION_PANE_TABS_QUERY_PARAM
|
|
) as TPageNavigationPaneTab | null;
|
|
|
|
const isNavigationPaneOpen =
|
|
!!navigationPaneQueryParam && PAGE_NAVIGATION_PANE_TAB_KEYS.includes(navigationPaneQueryParam);
|
|
|
|
const handleOpenNavigationPane = useCallback(() => {
|
|
const updatedRoute = updateQueryParams({
|
|
paramsToAdd: { [PAGE_NAVIGATION_PANE_TABS_QUERY_PARAM]: "outline" },
|
|
});
|
|
router.push(updatedRoute);
|
|
}, [router, updateQueryParams]);
|
|
|
|
const editorExtensionHandlers: Map<string, unknown> = useMemo(() => {
|
|
const map: Map<string, unknown> = new Map();
|
|
return map;
|
|
}, []);
|
|
|
|
const navigationPaneExtensions: INavigationPaneExtension[] = [];
|
|
|
|
return {
|
|
editorExtensionHandlers,
|
|
navigationPaneExtensions,
|
|
handleOpenNavigationPane,
|
|
isNavigationPaneOpen,
|
|
};
|
|
};
|