AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
fix(web): align AI assistant launcher with outline content
tianma-if86091392c4f2
diff --git a/apps/web/src/components/EditorOutline.tsx b/apps/web/src/components/EditorOutline.tsxindex 54a920d2..2fec81d6 100644--- a/apps/web/src/components/EditorOutline.tsx+++ b/apps/web/src/components/EditorOutline.tsx@@ -1,4 +1,4 @@-import { useCallback, useEffect, useMemo, useRef, useState, type RefObject } from "react";+import { useCallback, useEffect, useMemo, useRef, useState, type Ref, type RefObject } from "react";import { createPortal } from "react-dom";import type { Transaction } from "@tiptap/pm/state";import type { Editor } from "@tiptap/react";@@ -21,6 +21,7 @@ type EditorOutlineProps = {collapsed: boolean;shortcutLabel: string;onCollapsedChange: (collapsed: boolean) => void;+ contentRef?: Ref<HTMLElement>;};const OUTLINE_INDENT = 12;@@ -53,7 +54,7 @@ const sameOutlineItems = (left: OutlineItem[], right: OutlineItem[]) =>return other?.level === item.level && other.pos === item.pos && other.text === item.text;});-export const EditorOutline = ({ editor, memoId, editingMemoIdRef, scrollContainer, collapsedAnchor, collapsed, shortcutLabel, onCollapsedChange }: EditorOutlineProps) => {+export const EditorOutline = ({ editor, memoId, editingMemoIdRef, scrollContainer, collapsedAnchor, collapsed, shortcutLabel, onCollapsedChange, contentRef }: EditorOutlineProps) => {const { t } = useTranslation();const [items, setItems] = useState<OutlineItem[]>([]);const [activePos, setActivePos] = useState<number | null>(null);@@ -377,7 +378,7 @@ export const EditorOutline = ({ editor, memoId, editingMemoIdRef, scrollContaine</div>{!collapsed && (- <nav className="pr-2" aria-label={t("editor.outline")}>+ <nav ref={contentRef} className="pr-2" aria-label={t("editor.outline")}>{renderItems(tree)}</nav>)}diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsxindex 0a073325..c4732911 100644--- a/apps/web/src/components/EditorPane.tsx+++ b/apps/web/src/components/EditorPane.tsx@@ -1,3 +1,4 @@+import { autoUpdate } from "@floating-ui/react-dom";import { AI_ASSISTANT_LAUNCHER_POSITION } from "@/lib/ai-assistant-launcher";import { editorClipboardTextSerializer } from "@/lib/editor-clipboard";import { useRef, useState, useEffect, useLayoutEffect, useCallback, useMemo, lazy, Suspense, type CSSProperties, type FocusEvent as ReactFocusEvent, type MouseEvent as ReactMouseEvent, type ReactNode } from "react";@@ -626,6 +627,23 @@ const RichEditorPane = ({});const [editorScrollContainer, setEditorScrollContainer] = useState<HTMLDivElement | null>(null);const [collapsedOutlineAnchor, setCollapsedOutlineAnchor] = useState<HTMLDivElement | null>(null);+ const [outlineContent, setOutlineContent] = useState<HTMLElement | null>(null);+ const [aiLauncher, setAiLauncher] = useState<HTMLButtonElement | null>(null);+ useLayoutEffect(() => {+ if (!outlineContent || !aiLauncher) return;+ const container = aiLauncher.offsetParent;+ if (!(container instanceof HTMLElement)) return;+ // Follow the visible content edge, excluding the outline's scrollbar and+ // inner padding. Frame tracking also covers the reading-gutter transition.+ return autoUpdate(outlineContent, aiLauncher, () => {+ const contentRight = outlineContent.getBoundingClientRect().right+ - Number.parseFloat(getComputedStyle(outlineContent).paddingRight || "0");+ aiLauncher.style.right = `${container.getBoundingClientRect().right - contentRight}px`;+ }, { animationFrame: true });+ }, [outlineContent, aiLauncher]);+ useLayoutEffect(() => {+ if (!outlineContent) aiLauncher?.style.removeProperty("right");+ }, [outlineContent, aiLauncher]);const [editorScrollbarGutter, setEditorScrollbarGutter] = useState(0);const [headerTitleSlot, setHeaderTitleSlot] = useState<HTMLDivElement | null>(null);const [headerStatusCluster, setHeaderStatusCluster] = useState<HTMLDivElement | null>(null);@@ -4740,6 +4758,7 @@ const RichEditorPane = ({editingMemoIdRef={editingMemoIdRef}editor={editor}scrollContainer={editorScrollContainer}+ contentRef={setOutlineContent}collapsedAnchor={collapsedOutlineAnchor}collapsed={editorOutlineCollapsed}shortcutLabel={formatShortcutBinding(shortcutSettings.toggleOutline)}@@ -4852,6 +4871,7 @@ const RichEditorPane = ({type="button"variant="outline"size="icon"+ ref={setAiLauncher}data-ai-assistant-launcher=""className={cn("absolute z-30 size-11 rounded-full border-slate-200 bg-card text-slate-950 shadow-[0_8px_24px_rgba(15,23,42,0.14)] hover:bg-card hover:text-slate-950",