Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(comment): remove all hard break and squeeze to max 1 soft break #3976

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@keyv/redis": "^2.6.1",
"@matters/apollo-response-cache": "^2.0.0-alpha.0",
"@matters/ipns-site-generator": "^0.1.6",
"@matters/matters-editor": "^0.2.4",
"@matters/matters-editor": "^0.2.5-alpha.0",
"@matters/passport-likecoin": "^1.0.0",
"@matters/slugify": "^0.7.3",
"@sendgrid/helpers": "^7.7.0",
Expand Down
1 change: 0 additions & 1 deletion src/common/enums/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ export const MAX_ARTICLES_PER_CONNECTION_LIMIT = 3
export const MAX_ARTICLE_CONTENT_REVISION_LENGTH = 50

export const MAX_ARTICLE_COMMENT_LENGTH = 1200
export const MAX_COMMENT_EMPTY_PARAGRAPHS = 1

export const MAX_TAGS_PER_ARTICLE_LIMIT = 3
export const TAGS_RECOMMENDED_LIMIT = 100
Expand Down
5 changes: 4 additions & 1 deletion src/connectors/queue/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ export class MigrationQueue extends BaseQueue {
content:
content &&
normalizeArticleHTML(
sanitizeHTML(content, { maxEmptyParagraphs: -1 })
sanitizeHTML(content, {
maxHardBreaks: -1,
maxSoftBreaks: -1,
})
),
})

Expand Down
2 changes: 1 addition & 1 deletion src/mutations/article/editArticle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ const resolver: GQLMutationResolvers['editArticle'] = async (
const { content: lastContent } =
await atomService.articleContentIdLoader.load(articleVersion.contentId)
const processed = normalizeArticleHTML(
sanitizeHTML(content, { maxEmptyParagraphs: -1 })
sanitizeHTML(content, { maxHardBreaks: -1, maxSoftBreaks: -1 })
)
const changed = processed !== lastContent

Expand Down
4 changes: 2 additions & 2 deletions src/mutations/comment/putComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
COMMENT_TYPE,
DB_NOTICE_TYPE,
MAX_ARTICLE_COMMENT_LENGTH,
MAX_COMMENT_EMPTY_PARAGRAPHS,
NODE_TYPES,
USER_STATE,
} from 'common/enums'
Expand Down Expand Up @@ -76,7 +75,8 @@ const resolver: GQLMutationResolvers['putComment'] = async (
const data: Partial<Comment> & { mentionedUserIds?: any } = {
content: normalizeCommentHTML(
sanitizeHTML(content, {
maxEmptyParagraphs: MAX_COMMENT_EMPTY_PARAGRAPHS,
maxHardBreaks: 0,
maxSoftBreaks: 1,
})
),
authorId: viewer.id,
Expand Down
4 changes: 3 additions & 1 deletion src/mutations/draft/putDraft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ const resolver: GQLMutationResolvers['putDraft'] = async (
summary: summary === null ? null : summary?.trim(),
content:
content &&
normalizeArticleHTML(sanitizeHTML(content, { maxEmptyParagraphs: -1 })),
normalizeArticleHTML(
sanitizeHTML(content, { maxHardBreaks: -1, maxSoftBreaks: -1 })
),
tags: tags?.length === 0 ? null : tags,
cover: coverId,
collection: collection?.length === 0 ? null : collection,
Expand Down
Loading