diff --git a/apps/client/src/components/layouts/global/app-header.tsx b/apps/client/src/components/layouts/global/app-header.tsx index 68ed727..0e52f06 100644 --- a/apps/client/src/components/layouts/global/app-header.tsx +++ b/apps/client/src/components/layouts/global/app-header.tsx @@ -1,5 +1,4 @@ -import { Group } from "@mantine/core"; -import { IconSquareLetterDFilled } from "@tabler/icons-react"; +import { Group, Text } from "@mantine/core"; import classes from "./app-header.module.css"; import React from "react"; import TopMenu from "@/components/layouts/global/top-menu.tsx"; @@ -33,9 +32,7 @@ export function AppHeader() { return ( <> - - - + {!isHomeRoute && ( <> )} + + Docmost + + {items} diff --git a/apps/client/src/features/auth/components/auth.module.css b/apps/client/src/features/auth/components/auth.module.css index 8362636..958dccf 100644 --- a/apps/client/src/features/auth/components/auth.module.css +++ b/apps/client/src/features/auth/components/auth.module.css @@ -1,10 +1,3 @@ -.authBackground { - position: relative; - min-height: 100vh; - background-size: cover; - background-image: url(https://images.unsplash.com/photo-1701010063921-5f3255259e6d?q=80&w=3024&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D); -} - .container { box-shadow: rgba(0, 0, 0, 0.07) 0px 2px 45px 4px; border-radius: 4px; diff --git a/apps/client/src/features/editor/components/bubble-menu/bubble-menu.tsx b/apps/client/src/features/editor/components/bubble-menu/bubble-menu.tsx index eac1cfe..bfd6406 100644 --- a/apps/client/src/features/editor/components/bubble-menu/bubble-menu.tsx +++ b/apps/client/src/features/editor/components/bubble-menu/bubble-menu.tsx @@ -4,7 +4,7 @@ import { isNodeSelection, useEditor, } from "@tiptap/react"; -import { FC, memo, useEffect, useRef, useState } from "react"; +import { FC, useEffect, useRef, useState } from "react"; import { IconBold, IconCode, @@ -24,7 +24,7 @@ import { } from "@/features/comment/atoms/comment-atom"; import { useAtom } from "jotai"; import { v4 as uuidv4 } from "uuid"; -import { isCellSelection } from "@docmost/editor-ext"; +import { isCellSelection, isTextSelected } from "@docmost/editor-ext"; import { LinkSelector } from "@/features/editor/components/bubble-menu/link-selector.tsx"; export interface BubbleMenuItem { @@ -110,7 +110,7 @@ export const EditorBubbleMenu: FC = (props) => { ) { return false; } - return true; + return isTextSelected(editor); }, tippyOptions: { moveTransition: "transform 0.15s ease-out", diff --git a/apps/client/src/features/editor/components/bubble-menu/link-selector.tsx b/apps/client/src/features/editor/components/bubble-menu/link-selector.tsx index a3e2fd8..c9b9a08 100644 --- a/apps/client/src/features/editor/components/bubble-menu/link-selector.tsx +++ b/apps/client/src/features/editor/components/bubble-menu/link-selector.tsx @@ -4,11 +4,6 @@ import { ActionIcon, Popover, Tooltip } from "@mantine/core"; import { useEditor } from "@tiptap/react"; import { LinkEditorPanel } from "@/features/editor/components/link/link-editor-panel.tsx"; -export interface BubbleColorMenuItem { - name: string; - color: string; -} - interface LinkSelectorProps { editor: ReturnType; isOpen: boolean; @@ -22,11 +17,10 @@ export const LinkSelector: FC = ({ }) => { const onLink = useCallback( (url: string) => { - editor.chain().focus().setLink({ href: url }).run(); setIsOpen(false); - console.log("is p[e "); + editor.chain().focus().setLink({ href: url }).run(); }, - [editor], + [editor, setIsOpen], ); return ( diff --git a/apps/client/src/features/editor/components/callout/callout-menu.tsx b/apps/client/src/features/editor/components/callout/callout-menu.tsx index e80621b..1203ec6 100644 --- a/apps/client/src/features/editor/components/callout/callout-menu.tsx +++ b/apps/client/src/features/editor/components/callout/callout-menu.tsx @@ -61,7 +61,7 @@ export function CalloutMenu({ editor }: EditorMenuProps) { updateDelay={0} tippyOptions={{ getReferenceClientRect, - offset: [0, 2], + offset: [0, 10], placement: "bottom", zIndex: 99, popperOptions: { diff --git a/packages/editor-ext/src/lib/utils.ts b/packages/editor-ext/src/lib/utils.ts index e80a1d8..b457b11 100644 --- a/packages/editor-ext/src/lib/utils.ts +++ b/packages/editor-ext/src/lib/utils.ts @@ -1,5 +1,5 @@ // @ts-nocheck -import { Editor, findParentNode } from "@tiptap/core"; +import { Editor, findParentNode, isTextSelection } from "@tiptap/core"; import { Selection, Transaction } from "@tiptap/pm/state"; import { CellSelection, TableMap } from "@tiptap/pm/tables"; import { Node, ResolvedPos } from "@tiptap/pm/model"; @@ -345,15 +345,23 @@ export const isRowGripSelected = ({ return !!gripRow; }; -export function parseAttributes(value: string) { - const regex = /([^=\s]+)="?([^"]+)"?/g; - const attrs: Record = {}; - let match: RegExpExecArray | null; - // eslint-disable-next-line no-cond-assign - while ((match = regex.exec(value))) { - attrs[match[1]] = match[2]; +export function isTextSelected(editor: Editor) { + const { + state: { + doc, + selection, + selection: { empty, from, to }, + }, + } = editor; + + const isEmptyTextBlock = + !doc.textBetween(from, to).length && isTextSelection(selection); + + if (empty || isEmptyTextBlock || !editor.isEditable) { + return false; } - return attrs; + + return true; } export function setAttributes(