diff --git a/apps/web/src/components/editor/table-of-contents.tsx b/apps/web/src/components/editor/table-of-contents.tsx index 11892b7e3e..7ad164c5eb 100644 --- a/apps/web/src/components/editor/table-of-contents.tsx +++ b/apps/web/src/components/editor/table-of-contents.tsx @@ -149,7 +149,7 @@ function TableOfContents(props: TableOfContentsProps) { key={t.id} sx={{ textAlign: "left", - paddingLeft: `${t.level * 5}px`, + paddingLeft: `${t.level * 5 + (t.level - 1) * 5}px`, py: 1, pr: 1, borderLeft: "5px solid transparent", diff --git a/apps/web/src/components/editor/tiptap.tsx b/apps/web/src/components/editor/tiptap.tsx index ec5378c38e..7b03c2d7e0 100644 --- a/apps/web/src/components/editor/tiptap.tsx +++ b/apps/web/src/components/editor/tiptap.tsx @@ -245,10 +245,13 @@ function TipTap(props: TipTapProps) { onDestroy: () => { useEditorManager.getState().setEditor(id); }, - onTransaction: ({ editor }) => { + onTransaction: ({ editor, transaction }) => { useEditorManager.getState().updateEditor(id, { canRedo: editor.can().redo(), - canUndo: editor.can().undo() + canUndo: editor.can().undo(), + tableOfContents: transaction.getMeta("isUpdatingContent") + ? getTableOfContents(editor.view.dom) + : useEditorManager.getState().getEditor(id)?.tableOfContents }); }, copyToClipboard(text, html) { @@ -487,6 +490,7 @@ function toIEditor(editor: Editor): IEditor { ?.chain() .command(({ tr }) => { tr.setMeta("preventSave", true); + tr.setMeta("isUpdatingContent", true); return true; }) .setContent(content, false, { preserveWhitespace: true })