Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix(web): share AI assistant launcher positioning across editors

tianma-if96626ef24d90
diff --git a/apps/web/src/components/DiagramEditorPane.tsx b/apps/web/src/components/DiagramEditorPane.tsx
index b754ddbb..c242d977 100644
--- a/apps/web/src/components/DiagramEditorPane.tsx
+++ b/apps/web/src/components/DiagramEditorPane.tsx
@@ -1,3 +1,4 @@
+import { AI_ASSISTANT_LAUNCHER_POSITION } from "@/lib/ai-assistant-launcher";
import { diagramEditorSnapshot } from "@/lib/diagram-editor-snapshot";
import { formatMindMapOutline, projectMindMapOutline, updateMindMapOutlineDraft, type MindMapOutlineDraft, type MindMapOutlineError } from "@/lib/mind-map-outline";
import { MindMapOutlineEditor } from "@/components/MindMapOutlineEditor";
@@ -3910,7 +3911,7 @@ export const DiagramEditorPane = ({
variant="outline"
size="icon"
data-ai-assistant-launcher=""
- className="absolute bottom-[calc(1.25rem+env(safe-area-inset-bottom))] right-5 sm:bottom-[calc(2rem+env(safe-area-inset-bottom))] sm:right-8 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"
+ className={`${AI_ASSISTANT_LAUNCHER_POSITION} 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`}
aria-label={t("aiAssistant.open")}
onClick={() => {
setAiSidebarOpen(true);
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx
index 0e2ae0cc..c322e74f 100644
--- a/apps/web/src/components/EditorPane.tsx
+++ b/apps/web/src/components/EditorPane.tsx
@@ -1,3 +1,4 @@
+import { AI_ASSISTANT_LAUNCHER_POSITION } from "@/lib/ai-assistant-launcher";
import { useRef, useState, useEffect, useLayoutEffect, useCallback, useMemo, lazy, Suspense, type CSSProperties, type FocusEvent as ReactFocusEvent, type MouseEvent as ReactMouseEvent, type ReactNode } from "react";
import { useQuery, useQueryClient, useMutation } from "@tanstack/react-query";
import { useEditor, EditorContent, type Editor } from "@tiptap/react";
@@ -4586,7 +4587,7 @@ const RichEditorPane = ({
// The phone note view already has an edit button in this corner.
isMobileViewport && !mobileEditingActive
? "bottom-[calc(4.75rem+env(safe-area-inset-bottom))] right-4"
- : "bottom-[calc(1.25rem+env(safe-area-inset-bottom))] right-5 sm:bottom-[calc(2rem+env(safe-area-inset-bottom))] sm:right-8",
+ : AI_ASSISTANT_LAUNCHER_POSITION,
)}
aria-label={t("aiAssistant.open")}
onClick={openAiAssistant}
diff --git a/apps/web/src/components/InfographicEditorPane.tsx b/apps/web/src/components/InfographicEditorPane.tsx
index 0187e0fc..f309816c 100644
--- a/apps/web/src/components/InfographicEditorPane.tsx
+++ b/apps/web/src/components/InfographicEditorPane.tsx
@@ -1,3 +1,4 @@
+import { AI_ASSISTANT_LAUNCHER_POSITION } from "@/lib/ai-assistant-launcher";
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { Check, ChevronLeft, Download, FileCode2, FileImage, LayoutTemplate, LoaderCircle, Pencil, Sparkles } from "lucide-react";
import * as m from "motion/react-m";
@@ -768,7 +769,7 @@ export default function InfographicEditorPane({
variant="outline"
size="icon"
data-ai-assistant-launcher=""
- className="absolute bottom-[calc(1.25rem+env(safe-area-inset-bottom))] right-5 sm:bottom-[calc(2rem+env(safe-area-inset-bottom))] sm:right-8 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"
+ className={`${AI_ASSISTANT_LAUNCHER_POSITION} 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`}
aria-label={t("aiAssistant.open")}
onClick={() => setAiSidebarOpen(true)}
>
diff --git a/apps/web/src/components/PosterEditorPane.tsx b/apps/web/src/components/PosterEditorPane.tsx
index 70b528a0..130d39d0 100644
--- a/apps/web/src/components/PosterEditorPane.tsx
+++ b/apps/web/src/components/PosterEditorPane.tsx
@@ -1,3 +1,4 @@
+import { AI_ASSISTANT_LAUNCHER_POSITION } from "@/lib/ai-assistant-launcher";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import {
@@ -2095,7 +2096,7 @@ export default function PosterEditorPane({
</Dialog>
{!readOnly && !aiAssistantOpen && <IconTooltip side="left" label={t("aiAssistant.open")}>
<Button variant="outline" size="icon" data-ai-assistant-launcher="" aria-label={t("aiAssistant.open")}
- className="absolute bottom-[calc(4rem+env(safe-area-inset-bottom))] right-5 sm:bottom-[calc(4.75rem+env(safe-area-inset-bottom))] sm:right-8 z-30 size-11 rounded-full border-slate-200 bg-card text-slate-950 shadow-[0_8px_24px_rgba(15,23,42,0.14)]"
+ className={`${AI_ASSISTANT_LAUNCHER_POSITION} 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)]`}
onClick={() => setAiSidebarOpen(true)}><Sparkles className="size-5" strokeWidth={1.75} /></Button>
</IconTooltip>}
</div>
diff --git a/apps/web/src/components/TableEditorPane.tsx b/apps/web/src/components/TableEditorPane.tsx
index f208b036..63b5e637 100644
--- a/apps/web/src/components/TableEditorPane.tsx
+++ b/apps/web/src/components/TableEditorPane.tsx
@@ -1,3 +1,4 @@
+import { AI_ASSISTANT_LAUNCHER_POSITION } from "@/lib/ai-assistant-launcher";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useQuery } from "@tanstack/react-query";
import { flexRender, getCoreRowModel, useReactTable, type ColumnDef } from "@tanstack/react-table";
@@ -732,7 +733,7 @@ export const TableEditorPane = ({
variant="outline"
size="icon"
data-ai-assistant-launcher=""
- className="absolute bottom-[calc(1.25rem+env(safe-area-inset-bottom))] right-5 sm:bottom-[calc(2rem+env(safe-area-inset-bottom))] sm:right-8 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"
+ className={`${AI_ASSISTANT_LAUNCHER_POSITION} 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`}
aria-label={t("aiAssistant.open")}
onClick={() => {
setAiSidebarOpen(true);
diff --git a/apps/web/src/lib/ai-assistant-launcher.ts b/apps/web/src/lib/ai-assistant-launcher.ts
new file mode 100644
index 00000000..635b4c00
--- /dev/null
+++ b/apps/web/src/lib/ai-assistant-launcher.ts
@@ -0,0 +1,3 @@
+// Shared edge spacing for every note editor's floating AI assistant entry.
+export const AI_ASSISTANT_LAUNCHER_POSITION =
+ "bottom-[calc(1.25rem+env(safe-area-inset-bottom))] right-5 sm:bottom-[calc(2rem+env(safe-area-inset-bottom))] sm:right-8";