Fixes formatting issues with lists in event type description and bio (#7505)
* fix ul and ol in editor * fix imports * disable list for team about section * fix event type description in list --------- Co-authored-by: CarinaWolli <[email protected]> Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
14 files changed
+51
-46
No files matched your search
@@ -1,7 +1,6 @@
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import type { Prisma } from "@prisma/client";
|
||||
import { MembershipRole } from "@prisma/client";
|
||||
import MarkdownIt from "markdown-it";
|
||||
import { useSession } from "next-auth/react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
@@ -11,6 +10,7 @@ import { z } from "zod";
|
||||
import { IS_TEAM_BILLING_ENABLED, WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { getPlaceholderAvatar } from "@calcom/lib/getPlaceholderAvatar";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { md } from "@calcom/lib/markdownIt";
|
||||
import objectKeys from "@calcom/lib/objectKeys";
|
||||
import turndown from "@calcom/lib/turndownService";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
@@ -33,8 +33,6 @@ import { FiExternalLink, FiLink, FiTrash2, FiLogOut } from "@calcom/ui/component
|
||||
|
||||
import { getLayout } from "../../../settings/layouts/SettingsLayout";
|
||||
|
||||
const md = new MarkdownIt("default", { html: true, breaks: true });
|
||||
|
||||
const regex = new RegExp("^[a-zA-Z0-9-]*$");
|
||||
|
||||
const teamProfileFormSchema = z.object({
|
||||
@@ -225,6 +223,7 @@ const ProfileView = () => {
|
||||
getText={() => md.render(form.getValues("bio") || "")}
|
||||
setText={(value: string) => form.setValue("bio", turndown(value))}
|
||||
excludedToolbarItems={["blockType"]}
|
||||
disableLists
|
||||
/>
|
||||
</div>
|
||||
<p className="mt-2 text-sm text-gray-600">{t("team_description")}</p>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { SchedulingType } from "@prisma/client";
|
||||
import { isValidPhoneNumber } from "libphonenumber-js";
|
||||
import MarkdownIt from "markdown-it";
|
||||
import { useRouter } from "next/router";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
@@ -9,6 +8,7 @@ import { z } from "zod";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { useTypedQuery } from "@calcom/lib/hooks/useTypedQuery";
|
||||
import { HttpError } from "@calcom/lib/http-error";
|
||||
import { md } from "@calcom/lib/markdownIt";
|
||||
import slugify from "@calcom/lib/slugify";
|
||||
import turndown from "@calcom/lib/turndownService";
|
||||
import { createEventTypeInput } from "@calcom/prisma/zod/custom/eventtype";
|
||||
@@ -26,8 +26,6 @@ import {
|
||||
Editor,
|
||||
} from "@calcom/ui";
|
||||
|
||||
const md = new MarkdownIt("default", { html: true, breaks: true, linkify: true });
|
||||
|
||||
// this describes the uniform data needed to create a new event type on Profile or Team
|
||||
export interface EventTypeParent {
|
||||
teamId: number | null | undefined; // if undefined, then it's a profile
|
||||
@@ -203,26 +201,26 @@ export default function CreateEventTypeDialog() {
|
||||
message={form.formState.errors.schedulingType.message}
|
||||
/>
|
||||
)}
|
||||
<RadioArea.Group className="flex mt-1 space-x-4">
|
||||
<RadioArea.Group className="mt-1 flex space-x-4">
|
||||
<RadioArea.Item
|
||||
{...register("schedulingType")}
|
||||
value={SchedulingType.COLLECTIVE}
|
||||
className="w-1/2 text-sm">
|
||||
<strong className="block mb-1">{t("collective")}</strong>
|
||||
<strong className="mb-1 block">{t("collective")}</strong>
|
||||
<p>{t("collective_description")}</p>
|
||||
</RadioArea.Item>
|
||||
<RadioArea.Item
|
||||
{...register("schedulingType")}
|
||||
value={SchedulingType.ROUND_ROBIN}
|
||||
className="w-1/2 text-sm">
|
||||
<strong className="block mb-1">{t("round_robin")}</strong>
|
||||
<strong className="mb-1 block">{t("round_robin")}</strong>
|
||||
<p>{t("round_robin_description")}</p>
|
||||
</RadioArea.Item>
|
||||
</RadioArea.Group>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex flex-row-reverse mt-8 gap-x-2">
|
||||
<div className="mt-8 flex flex-row-reverse gap-x-2">
|
||||
<Button type="submit" loading={createMutation.isLoading}>
|
||||
{t("continue")}
|
||||
</Button>
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import { Prisma, SchedulingType } from "@prisma/client";
|
||||
import MarkdownIt from "markdown-it";
|
||||
import type { Prisma } from "@prisma/client";
|
||||
import { SchedulingType } from "@prisma/client";
|
||||
import { useMemo } from "react";
|
||||
import { FormattedNumber, IntlProvider } from "react-intl";
|
||||
import { z } from "zod";
|
||||
import type { z } from "zod";
|
||||
|
||||
import { classNames, parseRecurringEvent } from "@calcom/lib";
|
||||
import getPaymentAppData from "@calcom/lib/getPaymentAppData";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { baseEventTypeSelect } from "@calcom/prisma";
|
||||
import { EventTypeModel } from "@calcom/prisma/zod";
|
||||
import { addListFormatting, md } from "@calcom/lib/markdownIt";
|
||||
import type { baseEventTypeSelect } from "@calcom/prisma";
|
||||
import type { EventTypeModel } from "@calcom/prisma/zod";
|
||||
import { Badge } from "@calcom/ui";
|
||||
import {
|
||||
FiClock,
|
||||
@@ -29,11 +30,9 @@ export type EventTypeDescriptionProps = {
|
||||
seatsPerTimeSlot?: number;
|
||||
};
|
||||
className?: string;
|
||||
shortenDescription?: true;
|
||||
shortenDescription?: boolean;
|
||||
};
|
||||
|
||||
const md = new MarkdownIt("default", { html: true, breaks: false, linkify: true });
|
||||
|
||||
export const EventTypeDescription = ({
|
||||
eventType,
|
||||
className,
|
||||
@@ -58,9 +57,7 @@ export const EventTypeDescription = ({
|
||||
shortenDescription ? "line-clamp-4" : ""
|
||||
)}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: shortenDescription
|
||||
? md.render(eventType.description?.replace(/<p><br><\/p>|\n/g, " "))
|
||||
: md.render(eventType.description),
|
||||
__html: addListFormatting(md.render(eventType.description)),
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import MarkdownIt from "markdown-it";
|
||||
|
||||
export const md = new MarkdownIt("default", { html: true, breaks: true, linkify: true });
|
||||
|
||||
export function addListFormatting(html: string) {
|
||||
return html
|
||||
.replaceAll("<ul>", "<ul style='list-style-type: disc; list-style-position: inside; margin-left: 12px'>")
|
||||
.replaceAll(
|
||||
"<ol>",
|
||||
"<ol style='list-style-type: decimal; list-style-position: inside; margin-left: 12px'>"
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { PrismaClient, EventType } from "@prisma/client";
|
||||
import MarkdownIt from "markdown-it";
|
||||
|
||||
const md = new MarkdownIt("default", { html: true, breaks: true, linkify: true });
|
||||
import { md } from "@calcom/lib/markdownIt";
|
||||
|
||||
function parseAndSanitize(description: string) {
|
||||
const parsedMarkdown = md.render(description);
|
||||
|
||||
@@ -31,6 +31,7 @@ export type TextEditorProps = {
|
||||
variables?: string[];
|
||||
height?: string;
|
||||
placeholder?: string;
|
||||
disableLists?: boolean;
|
||||
};
|
||||
|
||||
const editorConfig = {
|
||||
@@ -74,7 +75,15 @@ export const Editor = (props: TextEditorProps) => {
|
||||
<ListPlugin />
|
||||
<LinkPlugin />
|
||||
<AutoLinkPlugin />
|
||||
<MarkdownShortcutPlugin transformers={TRANSFORMERS} />
|
||||
<MarkdownShortcutPlugin
|
||||
transformers={
|
||||
props.disableLists
|
||||
? TRANSFORMERS.filter((value, index) => {
|
||||
if (index !== 3 && index !== 4) return value;
|
||||
})
|
||||
: TRANSFORMERS
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</LexicalComposer>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
text-align: left;
|
||||
border-color: #D1D5DB;
|
||||
border-width: 1px;
|
||||
padding: 1px
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.editor-inner {
|
||||
@@ -37,6 +37,7 @@
|
||||
overflow: scroll;
|
||||
resize: vertical;
|
||||
height: auto;
|
||||
min-height: 40px;
|
||||
}
|
||||
|
||||
.editor-input {
|
||||
|
||||
Reference in new issue
Block a user