Skip to content

Commit 34077e6

Browse files
author
Rajat
committed
Interactivity in page builder
Fixes #651
1 parent cb3f0bf commit 34077e6

25 files changed

Lines changed: 493 additions & 300 deletions

File tree

apps/web/app/(with-contexts)/dashboard/(sidebar)/community/[id]/manage/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ export default function Page(props: {
571571
showToolbar={false}
572572
url={address.backend}
573573
refresh={refresh}
574+
mediaType="community"
574575
/>
575576
</div>
576577
<div className="flex items-center justify-between">

apps/web/app/(with-contexts)/dashboard/(sidebar)/product/[id]/content/section/[section]/lesson/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ export default function LessonPage() {
222222
}}
223223
url={address.backend}
224224
placeholder={TEXT_EDITOR_PLACEHOLDER}
225+
mediaType="lesson"
225226
/>
226227
{errors.content && (
227228
<p className="text-sm text-red-500">

apps/web/app/(with-contexts)/dashboard/(sidebar)/product/[id]/manage/components/product-details.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export default function ProductDetails({ product }: ProductDetailsProps) {
143143
}}
144144
url={address.backend}
145145
refresh={refresh}
146+
mediaType="course"
146147
/>
147148
</div>
148149

apps/web/app/api/media/[mediaId]/[type]/route.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,21 @@ async function isActionAllowed(
9191
}
9292

9393
switch (type) {
94-
case "course":
94+
case "course": {
95+
const escapedMediaId = mediaId.replace(
96+
/[.*+?^${}()|[\]\\]/g, // AI generated
97+
"\\$&",
98+
);
9599
const course = await CourseModel.findOne<InternalCourse>({
96100
domain: domain._id,
97-
"featuredImage.mediaId": mediaId,
101+
$or: [
102+
{ "featuredImage.mediaId": mediaId },
103+
{
104+
description: new RegExp(
105+
`"mediaId":"${escapedMediaId}"`,
106+
),
107+
},
108+
],
98109
});
99110
if (!course) {
100111
return false;
@@ -113,6 +124,7 @@ async function isActionAllowed(
113124
])
114125
);
115126
}
127+
}
116128
case "lesson":
117129
const lesson = await LessonModel.findOne<Lesson>({
118130
domain: domain._id,

apps/web/components/admin/blogs/editor/details.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export default function Details({ id }: DetailsProps) {
150150
onChange={(state: any) => setDescription(state)}
151151
url={address.backend}
152152
placeholder={TEXT_EDITOR_PLACEHOLDER}
153+
mediaType="course"
153154
/>
154155
<div>
155156
<Button type="submit" disabled={loading}>

apps/web/next-env.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
/// <reference types="next/navigation-types/compat/navigation" />
43
/// <reference path="./.next/types/routes.d.ts" />
54

65
// NOTE: This file should not be edited

packages/components-library/src/text-editor.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from "react";
22
import { WysiwygEditor as TextEditor } from "@courselit/text-editor";
3+
import type { MediaDeleteType } from "@courselit/text-editor";
34
export { emptyDoc } from "@courselit/text-editor";
45

56
export interface WysiwygEditorProps {
@@ -10,6 +11,7 @@ export interface WysiwygEditorProps {
1011
refresh?: number;
1112
url: string;
1213
placeholder?: string;
14+
mediaType?: MediaDeleteType;
1315
}
1416

1517
export default function Editor({
@@ -20,6 +22,7 @@ export default function Editor({
2022
refresh,
2123
url,
2224
placeholder,
25+
mediaType,
2326
}: WysiwygEditorProps) {
2427
return (
2528
<div className="text-editor">
@@ -32,6 +35,7 @@ export default function Editor({
3235
fontFamily={"inherit"}
3336
url={url}
3437
placeholder={placeholder}
38+
mediaType={mediaType}
3539
/>
3640
</div>
3741
);

packages/page-blocks/src/blocks/banner/admin-widget/custom-settings.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export default function CustomSettings({
138138
onChange={(state: any) => setDescription(state)}
139139
showToolbar={false}
140140
url={address.backend}
141+
mediaType="page"
141142
/>
142143
</div>
143144
</Form>
@@ -169,6 +170,7 @@ export default function CustomSettings({
169170
}
170171
showToolbar={false}
171172
url={address.backend}
173+
mediaType="page"
172174
/>
173175
</div>
174176
<FormField

packages/page-blocks/src/blocks/content/admin-widget.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export default function AdminWidget({
7171
onChange={(state: any) => setDescription(state)}
7272
showToolbar={false}
7373
url={address.backend}
74+
mediaType="page"
7475
/>
7576
</div>
7677
<Select

packages/page-blocks/src/blocks/faq/admin-widget/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export default function AdminWidget({
184184
onChange={(state: any) => setDescription(state)}
185185
showToolbar={false}
186186
url={address.backend}
187+
mediaType="page"
187188
/>
188189
</div>
189190
</Form>

0 commit comments

Comments
 (0)