Editor for event type description (#7450)

* add editor for event type description

* enable same things for markdownIt

* show links in blue

* fix placeholder design

* format description for event list

* limit event descript ot 4 lines in list

* shorten event-type description whenever needed

* add editor to create event type dialog

* fix link title in event type list

* Fix overwriting users column when saving event types (#7445)

* Only overwrite user column when present

* Clean up

* Merge branch 'main' into feat/editor-event-type-description

* Merge branch 'main' into feat/editor-event-type-description

# Conflicts:
#	apps/web/pages/settings/my-account/profile.tsx

* Linting

---------

Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: zomars <[email protected]>
This commit is contained in:
authored and GitHub committed 2023-03-02 12:55:25 -07:00
1 parent e12b21a73c
commit cfb625e934
10 files changed
+56 -39

No files matched your search

@@ -102,7 +102,7 @@ const BookingDescription: FC<Props> = (props) => {
)}
/>
</div>
<div className="max-w-[calc(100%_-_2rem)] flex-shrink break-words">
<div className="max-w-[calc(100%_-_2rem)] flex-shrink break-words [&_a]:text-blue-500 [&_a]:underline [&_a]:hover:text-blue-600">
<EventTypeDescriptionSafeHTML eventType={eventType} />
</div>
</div>
@@ -1,6 +1,7 @@
import { useAutoAnimate } from "@formkit/auto-animate/react";
import { zodResolver } from "@hookform/resolvers/zod";
import { isValidPhoneNumber } from "libphonenumber-js";
import MarkdownIt from "markdown-it";
import { Trans } from "next-i18next";
import Link from "next/link";
import type { EventTypeSetupProps, FormValues } from "pages/event-types/[type]";
@@ -14,13 +15,16 @@ import { getEventLocationType, MeetLocationType, LocationType } from "@calcom/ap
import { CAL_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { slugify } from "@calcom/lib/slugify";
import { Button, Label, Select, SettingsToggle, Skeleton, TextField } from "@calcom/ui";
import turndown from "@calcom/lib/turndownService";
import { Button, Editor, Label, Select, SettingsToggle, Skeleton, TextField } from "@calcom/ui";
import { FiEdit2, FiCheck, FiX, FiPlus } from "@calcom/ui/components/icon";
import { EditLocationDialog } from "@components/dialog/EditLocationDialog";
import type { SingleValueLocationOption, LocationOption } from "@components/ui/form/LocationSelect";
import LocationSelect from "@components/ui/form/LocationSelect";
const md = new MarkdownIt("default", { html: true, breaks: true, linkify: true });
const getLocationFromType = (
type: EventLocationType["type"],
locationOptions: Pick<EventTypeSetupProps, "locationOptions">["locationOptions"]
@@ -272,12 +276,15 @@ export const EventSetupTab = (
defaultValue={eventType.title}
{...formMethods.register("title")}
/>
<TextField
label={t("description")}
placeholder={t("quick_video_meeting")}
defaultValue={eventType.description ?? ""}
{...formMethods.register("description")}
/>
<div>
<Label>{t("description")}</Label>
<Editor
getText={() => md.render(formMethods.getValues("description") || eventType.description || "")}
setText={(value: string) => formMethods.setValue("description", turndown(value))}
excludedToolbarItems={["blockType"]}
placeholder={t("quick_video_meeting")}
/>
</div>
<TextField
required
label={t("URL")}
@@ -14,7 +14,7 @@ import { Avatar } from "@calcom/ui";
import type { IOnboardingPageProps } from "../../../pages/getting-started/[[...step]]";
const md = new MarkdownIt("default", { html: true, breaks: true });
const md = new MarkdownIt("default", { html: true, breaks: true, linkify: true });
type FormData = {
bio: string;
+1 -7
View File
@@ -124,13 +124,7 @@ async function getUserPageProps(context: GetStaticPropsContext) {
},
});
const md = new MarkdownIt("zero").enable([
//
"emphasis",
"list",
"newline",
"strikethrough",
]);
const md = new MarkdownIt("default", { html: true, breaks: true, linkify: true });
if (!user || !user.eventTypes.length) return { notFound: true };
+2 -1
View File
@@ -119,7 +119,7 @@ const Item = ({ type, group, readOnly }: { type: EventType; group: EventTypeGrou
<Link
href={`/event-types/${type.id}?tabName=setup`}
className="flex-1 overflow-hidden pr-4 text-sm"
title={`${type.title} ${type.description ? `– ${type.description}` : ""}`}>
title={type.title}>
<div>
<span
className="font-semibold text-gray-700 ltr:mr-1 rtl:ml-1"
@@ -142,6 +142,7 @@ const Item = ({ type, group, readOnly }: { type: EventType; group: EventTypeGrou
<EventTypeDescription
// @ts-expect-error FIXME: We have a type mismatch here @hariombalhara @sean-brydon
eventType={type}
shortenDescription
/>
</Link>
);
@@ -41,7 +41,7 @@ import { FiAlertTriangle, FiTrash2 } from "@calcom/ui/components/icon";
import TwoFactor from "@components/auth/TwoFactor";
import { UsernameAvailabilityField } from "@components/ui/UsernameAvailability";
const md = new MarkdownIt("default", { html: true, breaks: true });
const md = new MarkdownIt("default", { html: true, breaks: true, linkify: true });
const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
return (