feat: community comments support rich text and media array (#805)#807
Open
clbotdev wants to merge 3 commits into
Open
feat: community comments support rich text and media array (#805)#807clbotdev wants to merge 3 commits into
clbotdev wants to merge 3 commits into
Conversation
added 3 commits
June 19, 2026 18:09
The apps/web/models/CommunityComment.ts file had content: { type: String } on both
the ReplySchema and CommunityCommentSchema, causing Mongoose validation errors
when posting rich text content (which is an object, not a string).
The orm-models package already had the correct Mixed type, but the web app
model at apps/web/models/ was never updated to match. This caused:
- 'Cast to string failed' when posting comments with rich text content
- 'Cast to string failed' when posting replies with rich text content
Fixed by changing both content field definitions to use mongoose.Schema.Types.Mixed,
matching the CommunityPost schema pattern.
…courselit/orm-models Follow the Course.ts pattern — import InternalCommunityComment, InternalReply, and CommunityCommentSchema from @courselit/orm-models, wrap in mongoose.model(), and re-export types. Removes ~75 lines of duplicated schema and interface code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Community comments/replies now support rich text (ProseMirror) and media attachments, matching the feature set already available for community posts. Closes #805.
Changes
Backend
packages/orm-models/src/models/community-comment.ts— Changedcontentfield in bothCommunityCommentSchemaandReplySchemafromStringtomongoose.Schema.Types.Mixedto store ProseMirror documents. AddedTextEditorContenttype import to interfaces.apps/web/graphql/communities/helpers.ts— AddednormalizeTextEditorContent()call informatComment()to automatically convert existing string-based comments to ProseMirror format for backward compatibility.apps/web/graphql/communities/logic.ts— UpdatedpostComment()parameter type fromcontent: stringtocontent: TextEditorContent | string.apps/web/graphql/communities/mutation.ts— Updated GraphQL mutation to passcontentasJSONObjectand includemediainpostCommentarguments.apps/web/graphql/communities/types.ts— Updated GraphQL type definitions for comment content and media fields.packages/common-models/— Updated TypeScript interfaces to includeTextEditorContent | stringunion type for content.Frontend
apps/web/components/community/comment.tsx— Added rich text rendering using<TextRenderer>for ProseMirror content, with backward-compatible plain string display for existing comments. Added media display via<MediaPreview>.apps/web/components/community/comment-section.tsx— Replaced<Textarea>with<Editor>(TextEditor) for rich text input. Added media upload capabilities (file attachment popover, GIF selector, YouTube link). Updated GraphQL mutations to send content as JSON and include media array.Backward Compatibility
Existing string-based comments are automatically normalized to ProseMirror format via
normalizeTextEditorContent()in the GraphQL helper layer. The Mongoose schema acceptingMixedtype ensures old string values remain valid in the database. The frontend renders both formats seamlessly.