mirror of https://github.com/fantasticit/think.git
client: update tocs
This commit is contained in:
parent
ff5ee8de29
commit
97ae2d929f
|
@ -53,7 +53,6 @@ export const TableOfContentsWrapper = ({ editor }) => {
|
||||||
transaction.setMeta('addToHistory', false);
|
transaction.setMeta('addToHistory', false);
|
||||||
transaction.setMeta('preventUpdate', true);
|
transaction.setMeta('preventUpdate', true);
|
||||||
editor.view.dispatch(transaction);
|
editor.view.dispatch(transaction);
|
||||||
console.log(headings, arrToTree(headings));
|
|
||||||
|
|
||||||
setItems(headings);
|
setItems(headings);
|
||||||
editor.eventEmitter.emit('TableOfContents', arrToTree(headings));
|
editor.eventEmitter.emit('TableOfContents', arrToTree(headings));
|
||||||
|
|
|
@ -38,15 +38,14 @@ const Toc = ({ toc, collapsed }) => {
|
||||||
|
|
||||||
export const Tocs: React.FC<{ tocs: Array<IToc>; editor: Editor }> = ({ tocs = [], editor }) => {
|
export const Tocs: React.FC<{ tocs: Array<IToc>; editor: Editor }> = ({ tocs = [], editor }) => {
|
||||||
const [hasToc, toggleHasToc] = useToggle(false);
|
const [hasToc, toggleHasToc] = useToggle(false);
|
||||||
const [collapsed, toggleCollapsed] = useToggle(true);
|
const { width } = useDocumentStyle((width) => {
|
||||||
|
|
||||||
useDocumentStyle((width) => {
|
|
||||||
if (width === Width.fullWidth) {
|
if (width === Width.fullWidth) {
|
||||||
toggleCollapsed(true);
|
toggleCollapsed(true);
|
||||||
} else {
|
} else {
|
||||||
toggleCollapsed(false);
|
toggleCollapsed(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const [collapsed, toggleCollapsed] = useToggle(width === Width.fullWidth);
|
||||||
|
|
||||||
const getContainer = useCallback(() => {
|
const getContainer = useCallback(() => {
|
||||||
return document.querySelector(`#js-tocs-container`);
|
return document.querySelector(`#js-tocs-container`);
|
||||||
|
|
Loading…
Reference in New Issue