mirror of
https://github.com/docmost/docmost.git
synced 2026-05-20 16:44:05 +08:00
feat: enhance public sharing (#1057)
* fix tree nodes sort * remove comment mark in shares * remove clickoutside hook for now * feat: search in shared pages * fix user-select * use Link * render page icons
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from "react";
|
||||
import React from "react";
|
||||
import {
|
||||
ActionIcon,
|
||||
Affix,
|
||||
@@ -30,7 +30,12 @@ import {
|
||||
import { IconList } from "@tabler/icons-react";
|
||||
import { useToggleToc } from "@/features/share/hooks/use-toggle-toc.ts";
|
||||
import classes from "./share.module.css";
|
||||
import { useClickOutside } from "@mantine/hooks";
|
||||
import {
|
||||
SearchControl,
|
||||
SearchMobileControl,
|
||||
} from "@/features/search/components/search-control.tsx";
|
||||
import { ShareSearchSpotlight } from "@/features/search/share-search-spotlight";
|
||||
import { shareSearchSpotlight } from "@/features/search/constants";
|
||||
|
||||
const MemoizedSharedTree = React.memo(SharedTree);
|
||||
|
||||
@@ -54,21 +59,9 @@ export default function ShareShell({
|
||||
const { data } = useGetSharedPageTreeQuery(shareId);
|
||||
const readOnlyEditor = useAtomValue(readOnlyEditorAtom);
|
||||
|
||||
const [navbarOutside, setNavbarOutside] = useState<HTMLElement | null>(null);
|
||||
|
||||
useClickOutside(
|
||||
() => {
|
||||
if (mobileOpened) {
|
||||
toggleMobile();
|
||||
}
|
||||
},
|
||||
null,
|
||||
[navbarOutside],
|
||||
);
|
||||
|
||||
return (
|
||||
<AppShell
|
||||
header={{ height: 48 }}
|
||||
header={{ height: 50 }}
|
||||
{...(data?.pageTree?.length > 1 && {
|
||||
navbar: {
|
||||
width: 300,
|
||||
@@ -91,7 +84,7 @@ export default function ShareShell({
|
||||
>
|
||||
<AppShell.Header>
|
||||
<Group wrap="nowrap" justify="space-between" py="sm" px="xl">
|
||||
<Group>
|
||||
<Group wrap="nowrap">
|
||||
{data?.pageTree?.length > 1 && (
|
||||
<>
|
||||
<Tooltip label={t("Sidebar toggle")}>
|
||||
@@ -116,8 +109,21 @@ export default function ShareShell({
|
||||
</>
|
||||
)}
|
||||
</Group>
|
||||
|
||||
{shareId && (
|
||||
<Group visibleFrom="sm">
|
||||
<SearchControl onClick={shareSearchSpotlight.open} />
|
||||
</Group>
|
||||
)}
|
||||
|
||||
<Group>
|
||||
<>
|
||||
{shareId && (
|
||||
<Group hiddenFrom="sm">
|
||||
<SearchMobileControl onSearch={shareSearchSpotlight.open} />
|
||||
</Group>
|
||||
)}
|
||||
|
||||
<Tooltip label={t("Table of contents")} withArrow>
|
||||
<ActionIcon
|
||||
variant="default"
|
||||
@@ -149,11 +155,7 @@ export default function ShareShell({
|
||||
</AppShell.Header>
|
||||
|
||||
{data?.pageTree?.length > 1 && (
|
||||
<AppShell.Navbar
|
||||
p="md"
|
||||
className={classes.navbar}
|
||||
ref={setNavbarOutside}
|
||||
>
|
||||
<AppShell.Navbar p="md" className={classes.navbar}>
|
||||
<MemoizedSharedTree sharedPageTree={data} />
|
||||
</AppShell.Navbar>
|
||||
)}
|
||||
@@ -186,6 +188,8 @@ export default function ShareShell({
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</AppShell.Aside>
|
||||
|
||||
<ShareSearchSpotlight shareId={shareId} />
|
||||
</AppShell>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user