mirror of
https://github.com/docmost/docmost.git
synced 2025-11-13 20:02:38 +10:00
fixes and cleanups
This commit is contained in:
@ -1,5 +1,4 @@
|
|||||||
import { Group } from "@mantine/core";
|
import { Group, Text } from "@mantine/core";
|
||||||
import { IconSquareLetterDFilled } from "@tabler/icons-react";
|
|
||||||
import classes from "./app-header.module.css";
|
import classes from "./app-header.module.css";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import TopMenu from "@/components/layouts/global/top-menu.tsx";
|
import TopMenu from "@/components/layouts/global/top-menu.tsx";
|
||||||
@ -33,9 +32,7 @@ export function AppHeader() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Group h="100%" px="md" justify="space-between" wrap={"nowrap"}>
|
<Group h="100%" px="md" justify="space-between" wrap={"nowrap"}>
|
||||||
<Group>
|
<Group wrap="nowrap">
|
||||||
<IconSquareLetterDFilled size={30} />
|
|
||||||
|
|
||||||
{!isHomeRoute && (
|
{!isHomeRoute && (
|
||||||
<>
|
<>
|
||||||
<SidebarToggle
|
<SidebarToggle
|
||||||
@ -56,6 +53,14 @@ export function AppHeader() {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<Text
|
||||||
|
size="lg"
|
||||||
|
fw={600}
|
||||||
|
style={{ cursor: "pointer", userSelect: "none" }}
|
||||||
|
>
|
||||||
|
Docmost
|
||||||
|
</Text>
|
||||||
|
|
||||||
<Group ml={50} gap={5} className={classes.links} visibleFrom="sm">
|
<Group ml={50} gap={5} className={classes.links} visibleFrom="sm">
|
||||||
{items}
|
{items}
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@ -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 {
|
.container {
|
||||||
box-shadow: rgba(0, 0, 0, 0.07) 0px 2px 45px 4px;
|
box-shadow: rgba(0, 0, 0, 0.07) 0px 2px 45px 4px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import {
|
|||||||
isNodeSelection,
|
isNodeSelection,
|
||||||
useEditor,
|
useEditor,
|
||||||
} from "@tiptap/react";
|
} from "@tiptap/react";
|
||||||
import { FC, memo, useEffect, useRef, useState } from "react";
|
import { FC, useEffect, useRef, useState } from "react";
|
||||||
import {
|
import {
|
||||||
IconBold,
|
IconBold,
|
||||||
IconCode,
|
IconCode,
|
||||||
@ -24,7 +24,7 @@ import {
|
|||||||
} from "@/features/comment/atoms/comment-atom";
|
} from "@/features/comment/atoms/comment-atom";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { v4 as uuidv4 } from "uuid";
|
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";
|
import { LinkSelector } from "@/features/editor/components/bubble-menu/link-selector.tsx";
|
||||||
|
|
||||||
export interface BubbleMenuItem {
|
export interface BubbleMenuItem {
|
||||||
@ -110,7 +110,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return isTextSelected(editor);
|
||||||
},
|
},
|
||||||
tippyOptions: {
|
tippyOptions: {
|
||||||
moveTransition: "transform 0.15s ease-out",
|
moveTransition: "transform 0.15s ease-out",
|
||||||
|
|||||||
@ -4,11 +4,6 @@ import { ActionIcon, Popover, Tooltip } from "@mantine/core";
|
|||||||
import { useEditor } from "@tiptap/react";
|
import { useEditor } from "@tiptap/react";
|
||||||
import { LinkEditorPanel } from "@/features/editor/components/link/link-editor-panel.tsx";
|
import { LinkEditorPanel } from "@/features/editor/components/link/link-editor-panel.tsx";
|
||||||
|
|
||||||
export interface BubbleColorMenuItem {
|
|
||||||
name: string;
|
|
||||||
color: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface LinkSelectorProps {
|
interface LinkSelectorProps {
|
||||||
editor: ReturnType<typeof useEditor>;
|
editor: ReturnType<typeof useEditor>;
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@ -22,11 +17,10 @@ export const LinkSelector: FC<LinkSelectorProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const onLink = useCallback(
|
const onLink = useCallback(
|
||||||
(url: string) => {
|
(url: string) => {
|
||||||
editor.chain().focus().setLink({ href: url }).run();
|
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
console.log("is p[e ");
|
editor.chain().focus().setLink({ href: url }).run();
|
||||||
},
|
},
|
||||||
[editor],
|
[editor, setIsOpen],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -61,7 +61,7 @@ export function CalloutMenu({ editor }: EditorMenuProps) {
|
|||||||
updateDelay={0}
|
updateDelay={0}
|
||||||
tippyOptions={{
|
tippyOptions={{
|
||||||
getReferenceClientRect,
|
getReferenceClientRect,
|
||||||
offset: [0, 2],
|
offset: [0, 10],
|
||||||
placement: "bottom",
|
placement: "bottom",
|
||||||
zIndex: 99,
|
zIndex: 99,
|
||||||
popperOptions: {
|
popperOptions: {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { Editor, findParentNode } from "@tiptap/core";
|
import { Editor, findParentNode, isTextSelection } from "@tiptap/core";
|
||||||
import { Selection, Transaction } from "@tiptap/pm/state";
|
import { Selection, Transaction } from "@tiptap/pm/state";
|
||||||
import { CellSelection, TableMap } from "@tiptap/pm/tables";
|
import { CellSelection, TableMap } from "@tiptap/pm/tables";
|
||||||
import { Node, ResolvedPos } from "@tiptap/pm/model";
|
import { Node, ResolvedPos } from "@tiptap/pm/model";
|
||||||
@ -345,15 +345,23 @@ export const isRowGripSelected = ({
|
|||||||
return !!gripRow;
|
return !!gripRow;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function parseAttributes(value: string) {
|
export function isTextSelected(editor: Editor) {
|
||||||
const regex = /([^=\s]+)="?([^"]+)"?/g;
|
const {
|
||||||
const attrs: Record<string, string> = {};
|
state: {
|
||||||
let match: RegExpExecArray | null;
|
doc,
|
||||||
// eslint-disable-next-line no-cond-assign
|
selection,
|
||||||
while ((match = regex.exec(value))) {
|
selection: { empty, from, to },
|
||||||
attrs[match[1]] = match[2];
|
},
|
||||||
|
} = editor;
|
||||||
|
|
||||||
|
const isEmptyTextBlock =
|
||||||
|
!doc.textBetween(from, to).length && isTextSelection(selection);
|
||||||
|
|
||||||
|
if (empty || isEmptyTextBlock || !editor.isEditable) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return attrs;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setAttributes(
|
export function setAttributes(
|
||||||
|
|||||||
Reference in New Issue
Block a user