From 5d0326847b2c5e93cc10d64e52a613fb059c614f Mon Sep 17 00:00:00 2001 From: Nikita <93587872+ncarazon@users.noreply.github.com> Date: Thu, 12 Dec 2024 13:09:36 +0400 Subject: [PATCH] feat: mdx editor form field, integrate it to existing forms --- front_end/package-lock.json | 10 + front_end/package.json | 1 + .../accounts/profile/components/user_info.tsx | 37 +-- .../c/[slug]/settings/components/settings.tsx | 37 +-- .../questions/components/group_form.tsx | 98 ++++--- .../questions/components/notebook_form.tsx | 56 ++-- .../questions/components/question_form.tsx | 105 ++++---- front_end/src/app/globals.css | 11 + .../src/components/markdown_editor/index.tsx | 237 +---------------- .../markdown_editor/initialized_editor.tsx | 245 ++++++++++++++++++ front_end/src/components/ui/form_field.tsx | 64 ++++- .../src/components/ui/input_container.tsx | 37 ++- 12 files changed, 520 insertions(+), 418 deletions(-) create mode 100644 front_end/src/components/markdown_editor/initialized_editor.tsx diff --git a/front_end/package-lock.json b/front_end/package-lock.json index b19ab98f5..c65669551 100644 --- a/front_end/package-lock.json +++ b/front_end/package-lock.json @@ -55,6 +55,7 @@ "react-error-boundary": "^4.0.13", "react-hook-form": "^7.52.1", "react-hot-toast": "^2.4.1", + "react-merge-refs": "^2.1.1", "remark": "^15.0.1", "sass": "^1.77.6", "sharp": "^0.33.5", @@ -12928,6 +12929,15 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, + "node_modules/react-merge-refs": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/react-merge-refs/-/react-merge-refs-2.1.1.tgz", + "integrity": "sha512-jLQXJ/URln51zskhgppGJ2ub7b2WFKGq3cl3NYKtlHoTG+dN2q7EzWrn3hN3EgPsTMvpR9tpq5ijdp7YwFZkag==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/gregberge" + } + }, "node_modules/react-property": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/react-property/-/react-property-2.0.2.tgz", diff --git a/front_end/package.json b/front_end/package.json index 62623e903..3f00f6e35 100644 --- a/front_end/package.json +++ b/front_end/package.json @@ -59,6 +59,7 @@ "react-error-boundary": "^4.0.13", "react-hook-form": "^7.52.1", "react-hot-toast": "^2.4.1", + "react-merge-refs": "^2.1.1", "remark": "^15.0.1", "sass": "^1.77.6", "sharp": "^0.33.5", diff --git a/front_end/src/app/(main)/accounts/profile/components/user_info.tsx b/front_end/src/app/(main)/accounts/profile/components/user_info.tsx index 9c97f11cb..98d6b07a8 100644 --- a/front_end/src/app/(main)/accounts/profile/components/user_info.tsx +++ b/front_end/src/app/(main)/accounts/profile/components/user_info.tsx @@ -19,7 +19,12 @@ import { import CalibrationChart from "@/app/(main)/questions/track-record/components/charts/calibration_chart"; import MarkdownEditor from "@/components/markdown_editor"; import Button from "@/components/ui/button"; -import { FormError, Input, Textarea } from "@/components/ui/form_field"; +import { + FormError, + Input, + MarkdownEditorField, + Textarea, +} from "@/components/ui/form_field"; import { useAuth } from "@/contexts/auth_context"; import { UserProfile } from "@/types/users"; @@ -88,30 +93,12 @@ const UserInfo: FC = ({
{editMode ? ( - <> -