From f75d49f9b617e1ac1370e36e71b1869d3c52e6ca Mon Sep 17 00:00:00 2001 From: Johnny Date: Sat, 8 Aug 2026 08:58:07 +0800 Subject: [PATCH] fix(web): restore sidebar and outline behavior (#6161) --- web/package.json | 5 +- web/pnpm-lock.yaml | 9 + web/src/components/AppSidebar/AppSidebar.tsx | 2 +- web/src/components/AppSidebar/TagsSection.tsx | 6 +- .../CreateIdentityProviderDialog.tsx | 4 +- .../MemoContent/MemoMarkdownRenderer.tsx | 23 +-- web/src/components/MemoContent/index.tsx | 1 + .../MemoContent/markdown/AnchorLink.tsx | 3 +- web/src/components/MemoContent/pipeline.ts | 97 +++++++++ .../MemoDetailSidebar/MemoDetailSidebar.tsx | 8 +- .../MemoDetailSidebar/MemoOutline.tsx | 15 +- web/src/components/TagTree.tsx | 119 ++++++++++- web/src/components/UserMenu.tsx | 2 +- web/src/components/ui/popup.ts | 6 + web/src/locales/ar.json | 1 - web/src/locales/bg.json | 1 - web/src/locales/ca.json | 1 - web/src/locales/cs.json | 1 - web/src/locales/da.json | 1 - web/src/locales/de.json | 1 - web/src/locales/el.json | 1 - web/src/locales/en-GB.json | 1 - web/src/locales/en.json | 1 - web/src/locales/es.json | 1 - web/src/locales/et.json | 1 - web/src/locales/fa.json | 1 - web/src/locales/fi.json | 1 - web/src/locales/fr.json | 1 - web/src/locales/gl.json | 1 - web/src/locales/hi.json | 1 - web/src/locales/hr.json | 1 - web/src/locales/hu.json | 1 - web/src/locales/id.json | 1 - web/src/locales/it.json | 1 - web/src/locales/ja.json | 1 - web/src/locales/ka-GE.json | 1 - web/src/locales/ko.json | 1 - web/src/locales/lt.json | 1 - web/src/locales/lv.json | 1 - web/src/locales/mr.json | 1 - web/src/locales/nb.json | 1 - web/src/locales/nl.json | 1 - web/src/locales/pl.json | 1 - web/src/locales/pt-BR.json | 1 - web/src/locales/pt-PT.json | 1 - web/src/locales/ro.json | 1 - web/src/locales/ru.json | 1 - web/src/locales/sk.json | 1 - web/src/locales/sl.json | 1 - web/src/locales/sr.json | 1 - web/src/locales/sv.json | 1 - web/src/locales/th.json | 1 - web/src/locales/tr.json | 1 - web/src/locales/uk.json | 1 - web/src/locales/vi.json | 1 - web/src/locales/zh-Hans.json | 1 - web/src/locales/zh-Hant.json | 1 - web/src/pages/MemoDetail.tsx | 11 +- web/src/utils/markdown-manipulation.ts | 99 +++++---- .../utils/rehype-plugins/rehype-heading-id.ts | 55 +++-- web/tests/markdown-manipulation.test.ts | 49 ++++- web/tests/memo-outline-headings.test.tsx | 106 ++++++++++ web/tests/sidebar-row-grammar.test.tsx | 4 + web/tests/tag-tree-render.test.tsx | 188 +++++++++++++++++- 64 files changed, 689 insertions(+), 166 deletions(-) create mode 100644 web/src/components/MemoContent/pipeline.ts create mode 100644 web/tests/memo-outline-headings.test.tsx diff --git a/web/package.json b/web/package.json index 5d3c1390..4256b68b 100644 --- a/web/package.json +++ b/web/package.json @@ -47,9 +47,9 @@ "mdast-util-from-markdown": "^2.0.3", "mdast-util-gfm": "^3.1.0", "mermaid": "^11.14.0", + "micromark-extension-gfm": "^3.0.0", "micromark-util-decode-string": "^2.0.1", "micromark-util-normalize-identifier": "^2.0.1", - "micromark-extension-gfm": "^3.0.0", "react": "^19.2.6", "react-dom": "^19.2.6", "react-hot-toast": "^2.6.0", @@ -64,8 +64,11 @@ "remark-breaks": "^4.0.0", "remark-gfm": "^4.0.1", "remark-math": "^6.0.0", + "remark-parse": "^11.0.0", + "remark-rehype": "^11.1.2", "tailwind-merge": "^3.5.0", "tailwindcss": "^4.2.4", + "unified": "^11.0.5", "unist-util-visit": "^5.1.0" }, "devDependencies": { diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index e6f04876..7d92b97f 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -152,12 +152,21 @@ importers: remark-math: specifier: ^6.0.0 version: 6.0.0 + remark-parse: + specifier: ^11.0.0 + version: 11.0.0 + remark-rehype: + specifier: ^11.1.2 + version: 11.1.2 tailwind-merge: specifier: ^3.5.0 version: 3.5.0 tailwindcss: specifier: ^4.2.4 version: 4.2.4 + unified: + specifier: ^11.0.5 + version: 11.0.5 unist-util-visit: specifier: ^5.1.0 version: 5.1.0 diff --git a/web/src/components/AppSidebar/AppSidebar.tsx b/web/src/components/AppSidebar/AppSidebar.tsx index c750b54a..d6a85a2b 100644 --- a/web/src/components/AppSidebar/AppSidebar.tsx +++ b/web/src/components/AppSidebar/AppSidebar.tsx @@ -249,7 +249,7 @@ const CollectionSidebarContent = ({ context }: { context: MemoStatsContext }) => setMobileOpen(false)} /> {showViews && } - setMobileOpen(false)} /> + setMobileOpen(false)} /> ); }; diff --git a/web/src/components/AppSidebar/TagsSection.tsx b/web/src/components/AppSidebar/TagsSection.tsx index 6a6ab9c2..4ee450a8 100644 --- a/web/src/components/AppSidebar/TagsSection.tsx +++ b/web/src/components/AppSidebar/TagsSection.tsx @@ -15,6 +15,8 @@ interface Props { onSelect?: () => void; /** When set, tag clicks land on this route with the tag filter instead of filtering the current one. */ navigationTarget?: string; + /** Whose tags these are; keeps tree expansion state from bleeding between users and views. */ + scope: string; } const TagPath = forwardRef(({ tag }, ref) => { @@ -58,7 +60,7 @@ const FlatTagRow = ({ tag, amount, active, onClick }: FlatTagRowProps) => { ); }; -const TagsSection = ({ tagCount, onSelect, navigationTarget }: Props) => { +const TagsSection = ({ tagCount, onSelect, navigationTarget, scope }: Props) => { const t = useTranslate(); const navigate = useNavigate(); const { filters, setFilters, getFiltersByFactor, addFilter, removeFilter } = useMemoFilterContext(); @@ -123,7 +125,7 @@ const TagsSection = ({ tagCount, onSelect, navigationTarget }: Props) => { {treeMode ? ( - + ) : (
{tags.map(([tag, amount]) => ( diff --git a/web/src/components/CreateIdentityProviderDialog.tsx b/web/src/components/CreateIdentityProviderDialog.tsx index 961441fa..76187d67 100644 --- a/web/src/components/CreateIdentityProviderDialog.tsx +++ b/web/src/components/CreateIdentityProviderDialog.tsx @@ -241,7 +241,9 @@ function FormField({ children: ReactNode; }) { return ( -
+ // flex gap, not space-y: fields wrap Select triggers, whose focus guards would otherwise + // pick up the stack's margin and shift the field while the popup is open (see ui/popup.ts). +