Skip to content

Commit

Permalink
Merge branch 'main' into pr/87
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-tey committed Aug 31, 2023
2 parents 096a08a + dba0eb1 commit 235a7bc
Show file tree
Hide file tree
Showing 8 changed files with 363 additions and 1,137 deletions.
8 changes: 6 additions & 2 deletions apps/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ Here's how you can contribute:
- [Open an issue](https://github.com/steven-tey/novel/issues) if you believe you've encountered a bug.
- Make a [pull request](https://github.com/steven-tey/novel/pull) to add new features/make quality-of-life improvements/fix bugs.

## Author
<a href="https://github.com/steven-tey/novel/graphs/contributors">
<img src="https://contrib.rocks/image?repo=steven-tey/novel" />
</a>

## Repo Activity

- Steven Tey ([@steventey](https://twitter.com/steventey))
![Novel.sh repo activity – generated by Axiom](https://repobeats.axiom.co/api/embed/2ebdaa143b0ad6e7c2ee23151da7b37f67da0b36.svg)

## License

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
"@vercel/analytics": "^1.0.1",
"@vercel/blob": "^0.9.3",
"@vercel/kv": "^0.2.2",
"ai": "^2.1.32",
"ai": "^2.2.9",
"clsx": "^1.2.1",
"eslint": "8.36.0",
"eslint-config-next": "13.2.4",
"eventsource-parser": "^0.1.0",
"framer-motion": "^10.15.1",
"lucide-react": "^0.244.0",
"next": "13.4.10-canary.0",
"next": "13.4.20-canary.9",
"next-themes": "^0.2.1",
"openai-edge": "^1.2.2",
"react": "18.2.0",
Expand Down
1 change: 1 addition & 0 deletions packages/novel/src/ui/editor/components/bubble-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
key={index}
onClick={item.command}
className="p-2 text-stone-600 hover:bg-stone-100 active:bg-stone-200"
type="button"
>
<item.icon
className={cn("h-4 w-4", {
Expand Down
46 changes: 26 additions & 20 deletions packages/novel/src/ui/editor/components/color-selector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Editor } from "@tiptap/core";
import { Check, ChevronDown } from "lucide-react";
import { Dispatch, FC, SetStateAction } from "react";
import * as Popover from "@radix-ui/react-popover";

export interface BubbleColorMenuItem {
name: string;
Expand Down Expand Up @@ -105,26 +106,29 @@ export const ColorSelector: FC<ColorSelectorProps> = ({
);

return (
<div className="relative h-full">
<button
className="flex h-full items-center gap-1 p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200"
onClick={() => setIsOpen(!isOpen)}
>
<span
className="rounded-sm px-1"
style={{
color: activeColorItem?.color,
backgroundColor: activeHighlightItem?.color,
}}
<Popover.Root open={isOpen}>
<div className="relative h-full">
<Popover.Trigger
className="flex h-full items-center gap-1 p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200"
onClick={() => setIsOpen(!isOpen)}
>
A
</span>
<span
className="rounded-sm px-1"
style={{
color: activeColorItem?.color,
backgroundColor: activeHighlightItem?.color,
}}
>
A
</span>

<ChevronDown className="h-4 w-4" />
</button>
<ChevronDown className="h-4 w-4" />
</Popover.Trigger>

{isOpen && (
<section className="fixed top-full z-[99999] mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1">
<Popover.Content
align="start"
className="z-[99999] my-1 flex max-h-80 w-48 flex-col overflow-hidden overflow-y-auto rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1"
>
<div className="my-1 px-2 text-sm text-stone-500">Color</div>
{TEXT_COLORS.map(({ name, color }, index) => (
<button
Expand All @@ -140,6 +144,7 @@ export const ColorSelector: FC<ColorSelectorProps> = ({
setIsOpen(false);
}}
className="flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100"
type="button"
>
<div className="flex items-center space-x-2">
<div
Expand Down Expand Up @@ -169,6 +174,7 @@ export const ColorSelector: FC<ColorSelectorProps> = ({
setIsOpen(false);
}}
className="flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100"
type="button"
>
<div className="flex items-center space-x-2">
<div
Expand All @@ -184,8 +190,8 @@ export const ColorSelector: FC<ColorSelectorProps> = ({
)}
</button>
))}
</section>
)}
</div>
</Popover.Content>
</div>
</Popover.Root>
);
};
2 changes: 2 additions & 0 deletions packages/novel/src/ui/editor/components/link-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const LinkSelector: FC<LinkSelectorProps> = ({
return (
<div className="relative">
<button
type="button"
className="flex h-full items-center space-x-2 px-3 py-1.5 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200"
onClick={() => {
setIsOpen(!isOpen);
Expand Down Expand Up @@ -58,6 +59,7 @@ export const LinkSelector: FC<LinkSelectorProps> = ({
/>
{editor.getAttributes("link").href ? (
<button
type="button"
className="flex items-center rounded-sm p-1 text-red-600 transition-all hover:bg-red-100 dark:hover:bg-red-800"
onClick={() => {
editor.chain().focus().unsetLink().run();
Expand Down
32 changes: 18 additions & 14 deletions packages/novel/src/ui/editor/components/node-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
Code,
CheckSquare,
} from "lucide-react";
import * as Popover from "@radix-ui/react-popover";
import { Dispatch, FC, SetStateAction } from "react";

import { BubbleMenuItem } from "./bubble-menu";

interface NodeSelectorProps {
Expand Down Expand Up @@ -99,17 +99,20 @@ export const NodeSelector: FC<NodeSelectorProps> = ({
};

return (
<div className="relative h-full">
<button
className="flex h-full items-center gap-1 whitespace-nowrap p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200"
onClick={() => setIsOpen(!isOpen)}
>
<span>{activeItem?.name}</span>
<ChevronDown className="h-4 w-4" />
</button>
<Popover.Root open={isOpen}>
<div className="relative h-full">
<Popover.Trigger
className="flex h-full items-center gap-1 whitespace-nowrap p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200"
onClick={() => setIsOpen(!isOpen)}
>
<span>{activeItem?.name}</span>
<ChevronDown className="h-4 w-4" />
</Popover.Trigger>

{isOpen && (
<section className="fixed top-full z-[99999] mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1">
<Popover.Content
align="start"
className="z-[99999] my-1 flex max-h-80 w-48 flex-col overflow-hidden overflow-y-auto rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1"
>
{items.map((item, index) => (
<button
key={index}
Expand All @@ -118,6 +121,7 @@ export const NodeSelector: FC<NodeSelectorProps> = ({
setIsOpen(false);
}}
className="flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100"
type="button"
>
<div className="flex items-center space-x-2">
<div className="rounded-sm border border-stone-200 p-1">
Expand All @@ -128,8 +132,8 @@ export const NodeSelector: FC<NodeSelectorProps> = ({
{activeItem.name === item.name && <Check className="h-4 w-4" />}
</button>
))}
</section>
)}
</div>
</Popover.Content>
</div>
</Popover.Root>
);
};
7 changes: 4 additions & 3 deletions packages/novel/src/ui/editor/extensions/slash-command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ const CommandList = ({
to: range.from + completion.length,
});
},
onError: () => {
toast.error("Something went wrong.");
onError: (e) => {
toast.error(e.message);
},
});

Expand All @@ -287,6 +287,7 @@ const CommandList = ({
});
if (item) {
if (item.title === "Continue writing") {
if (isLoading) return;
complete(
getPrevText(editor, {
chars: 5000,
Expand All @@ -298,7 +299,7 @@ const CommandList = ({
}
}
},
[complete, command, editor, items],
[complete, isLoading, command, editor, items],
);

useEffect(() => {
Expand Down
Loading

0 comments on commit 235a7bc

Please sign in to comment.