client: update tocs

pull/60/head
fantasticit 2022-05-28 14:03:40 +08:00
parent ff5ee8de29
commit 97ae2d929f
2 changed files with 2 additions and 4 deletions

View File

@ -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));

View File

@ -38,15 +38,14 @@ const Toc = ({ toc, collapsed }) => {
export const Tocs: React.FC<{ tocs: Array<IToc>; 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`);