From 97ae2d929f185c5f89f16c09cf51dc1fbd2d530c Mon Sep 17 00:00:00 2001 From: fantasticit Date: Sat, 28 May 2022 14:03:40 +0800 Subject: [PATCH] client: update tocs --- .../src/tiptap/core/wrappers/table-of-contents/index.tsx | 1 - packages/client/src/tiptap/editor/tocs/index.tsx | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/client/src/tiptap/core/wrappers/table-of-contents/index.tsx b/packages/client/src/tiptap/core/wrappers/table-of-contents/index.tsx index db7fc163..5f1bf2ad 100644 --- a/packages/client/src/tiptap/core/wrappers/table-of-contents/index.tsx +++ b/packages/client/src/tiptap/core/wrappers/table-of-contents/index.tsx @@ -53,7 +53,6 @@ export const TableOfContentsWrapper = ({ editor }) => { transaction.setMeta('addToHistory', false); transaction.setMeta('preventUpdate', true); editor.view.dispatch(transaction); - console.log(headings, arrToTree(headings)); setItems(headings); editor.eventEmitter.emit('TableOfContents', arrToTree(headings)); diff --git a/packages/client/src/tiptap/editor/tocs/index.tsx b/packages/client/src/tiptap/editor/tocs/index.tsx index 69a4a49b..8fc97374 100644 --- a/packages/client/src/tiptap/editor/tocs/index.tsx +++ b/packages/client/src/tiptap/editor/tocs/index.tsx @@ -38,15 +38,14 @@ const Toc = ({ toc, collapsed }) => { export const Tocs: React.FC<{ tocs: Array; editor: Editor }> = ({ tocs = [], editor }) => { const [hasToc, toggleHasToc] = useToggle(false); - const [collapsed, toggleCollapsed] = useToggle(true); - - useDocumentStyle((width) => { + const { width } = useDocumentStyle((width) => { if (width === Width.fullWidth) { toggleCollapsed(true); } else { toggleCollapsed(false); } }); + const [collapsed, toggleCollapsed] = useToggle(width === Width.fullWidth); const getContainer = useCallback(() => { return document.querySelector(`#js-tocs-container`);