diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index fe2b121..6b700a5 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -21,7 +21,7 @@ jobs: - run: pnpm install --ignore-scripts - run: pnpm wxt prepare - run: pnpm run lint - - run: pnpm run tsc + - run: pnpm run check release: needs: linter diff --git a/.husky/pre-commit b/.husky/pre-commit index 31eaf1e..d8e461b 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,2 +1,2 @@ -pnpm lint-staged && pnpm tsc +pnpm lint-staged && pnpm check diff --git a/eslint.config.ts b/eslint.config.ts index e58683f..943cd60 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -1,4 +1,4 @@ -import type { Linter } from 'eslint' +// import type { Linter } from 'eslint' import globals from 'globals' import pluginJs from '@eslint/js' import tseslint from 'typescript-eslint' diff --git a/package.json b/package.json index 82e9733..273961f 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "pack:firefox": "wxt zip -b firefox", "lint": "eslint --fix --flag unstable_ts_config", "clear": "rimraf .output", - "tsc": "tsc --noEmit", + "check": "tsc --noEmit", "prepare": "husky", "postinstall": "wxt prepare" }, @@ -54,6 +54,8 @@ "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-label": "^2.1.0", "@radix-ui/react-popover": "^1.1.2", + "@radix-ui/react-portal": "^1.1.2", + "@radix-ui/react-presence": "^1.1.1", "@radix-ui/react-radio-group": "^1.2.1", "@radix-ui/react-scroll-area": "^1.2.0", "@radix-ui/react-slot": "^1.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9db92b1..f413aaf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,6 +38,12 @@ importers: '@radix-ui/react-popover': specifier: ^1.1.2 version: 1.1.2(@types/react-dom@18.3.1)(@types/react@18.3.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@radix-ui/react-portal': + specifier: ^1.1.2 + version: 1.1.2(@types/react-dom@18.3.1)(@types/react@18.3.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@radix-ui/react-presence': + specifier: ^1.1.1 + version: 1.1.1(@types/react-dom@18.3.1)(@types/react@18.3.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@radix-ui/react-radio-group': specifier: ^1.2.1 version: 1.2.1(@types/react-dom@18.3.1)(@types/react@18.3.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) diff --git a/src/app/content/components/MessageInput.tsx b/src/app/content/components/MessageInput.tsx index 706845a..b523a58 100644 --- a/src/app/content/components/MessageInput.tsx +++ b/src/app/content/components/MessageInput.tsx @@ -1,8 +1,7 @@ import { forwardRef, type ChangeEvent, CompositionEvent, type KeyboardEvent } from 'react' -import { Textarea } from '@/components/ui/Textarea' -import { Markdown } from '@/components/Markdown' import { cn } from '@/utils' +import { Textarea } from '@/components/ui/Textarea' import { ScrollArea } from '@/components/ui/ScrollArea' export interface MessageInputProps { @@ -13,11 +12,16 @@ export interface MessageInputProps { autoFocus?: boolean disabled?: boolean onInput?: (e: ChangeEvent) => void - onEnter?: (e: KeyboardEvent) => void + onKeyDown?: (e: KeyboardEvent) => void onCompositionStart?: (e: CompositionEvent) => void onCompositionEnd?: (e: CompositionEvent) => void } +/** + * Need @ syntax highlighting? Waiting for textarea to support Highlight API + * + * @see https://github.com/w3c/csswg-drafts/issues/4603 + */ const MessageInput = forwardRef( ( { @@ -25,44 +29,33 @@ const MessageInput = forwardRef( className, maxLength = 500, onInput, - onEnter, + onKeyDown, onCompositionStart, onCompositionEnd, - preview, autoFocus, disabled }, ref ) => { - const handleKeyDown = (e: KeyboardEvent) => { - if (e.key === 'Enter' && !(e.shiftKey || e.ctrlKey || e.altKey || e.metaKey)) { - e.preventDefault() - onEnter?.(e) - } - } - return (
- {preview ? ( - {value} - ) : ( - -