From 8640eb9f52b4928e7c6e6ae5c847d974c673e119 Mon Sep 17 00:00:00 2001 From: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Date: Tue, 24 Jan 2023 20:08:10 -0500 Subject: [PATCH] Ability to format user and team bio (#6572) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * use texteditor for bio * remove block types from about editor * add props to make editor height adjustable * set isDirty to true when about input is edited * add editor to getting-started * fix editor height * remove required error for onboarding * add helper function to check if parsed bio has text * add back commented code * fix onboarding tests for optional about field * rename function * parse team bio for read only members * code clean up * fix failing e2e because of missing test id * fix onboarding e2e test * add missing parse of user bio * Update apps/web/components/getting-started/steps-views/UserProfile.tsx * Update apps/web/pages/settings/my-account/profile.tsx Co-authored-by: Omar López * use css inline style for height instead of tailwind class * fix height of editor-input * save bio as markdown in db * fix empty line when bio is empty * fix hydration failed error * Update packages/ui/components/editor/Editor.tsx Co-authored-by: Omar López * remove unused import Co-authored-by: CarinaWolli Co-authored-by: Omar López Co-authored-by: Peer Richelsen --- .../steps-views/UserProfile.tsx | 40 +++++++----------- apps/web/components/team/screens/Team.tsx | 20 +++++++-- apps/web/package.json | 2 + apps/web/pages/[user].tsx | 18 ++++++-- .../web/pages/settings/my-account/profile.tsx | 19 +++++++-- apps/web/pages/team/[slug].tsx | 14 ++++++- apps/web/playwright/onboarding.e2e.ts | 19 +++------ .../ee/teams/pages/team-profile-view.tsx | 42 +++++++++---------- .../components/WorkflowStepContainer.tsx | 1 + .../components/MultiDropdownSelect.tsx | 1 + packages/lib/turndownService.ts | 12 ++++++ packages/ui/components/editor/Editor.tsx | 8 +++- .../ui/components/editor/stylesEditor.css | 6 +-- 13 files changed, 125 insertions(+), 77 deletions(-) create mode 100644 packages/lib/turndownService.ts diff --git a/apps/web/components/getting-started/steps-views/UserProfile.tsx b/apps/web/components/getting-started/steps-views/UserProfile.tsx index 455d04a245..1cb8f91ea1 100644 --- a/apps/web/components/getting-started/steps-views/UserProfile.tsx +++ b/apps/web/components/getting-started/steps-views/UserProfile.tsx @@ -1,15 +1,19 @@ import { ArrowRightIcon } from "@heroicons/react/solid"; +import MarkdownIt from "markdown-it"; import { useRouter } from "next/router"; import { FormEvent, useRef, useState } from "react"; import { useForm } from "react-hook-form"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import turndownService from "@calcom/lib/turndownService"; import { trpc } from "@calcom/trpc/react"; -import { Button, ImageUploader, showToast, TextArea } from "@calcom/ui"; +import { Button, Editor, ImageUploader, Label, showToast } from "@calcom/ui"; import { Avatar } from "@calcom/ui"; import type { IOnboardingPageProps } from "../../../pages/getting-started/[[...step]]"; +const md = new MarkdownIt("default", { html: true, breaks: true }); + type FormData = { bio: string; }; @@ -21,13 +25,10 @@ const UserProfile = (props: IUserProfileProps) => { const { user } = props; const { t } = useLocale(); const avatarRef = useRef(null!); - const bioRef = useRef(null); - const { - register, - setValue, - handleSubmit, - formState: { errors }, - } = useForm({ defaultValues: { bio: user?.bio || "" } }); + const { setValue, handleSubmit, getValues } = useForm({ + defaultValues: { bio: user?.bio || "" }, + }); + const { data: eventTypes } = trpc.viewer.eventTypes.list.useQuery(); const [imageSrc, setImageSrc] = useState(user?.avatar || ""); const utils = trpc.useContext(); @@ -138,25 +139,12 @@ const UserProfile = (props: IUserProfileProps) => {
- -