@selfcommunity/react-ui 0.7.0-alpha.324 → 0.7.0-alpha.326
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/CommentObject/CommentObject.d.ts +6 -0
- package/lib/cjs/components/CommentObject/CommentObject.js +4 -4
- package/lib/cjs/components/Editor/nodes/ImageNode.d.ts +2 -6
- package/lib/cjs/components/Editor/nodes/ImageNode.js +14 -23
- package/lib/cjs/components/Editor/plugins/ImagePlugin.js +10 -15
- package/lib/cjs/components/Editor/plugins/OnChangePlugin.js +0 -54
- package/lib/cjs/components/FeedObject/Activities/Activities.js +1 -1
- package/lib/cjs/components/FeedObject/Activities/RelevantActivities/CommentActivity/CommentActivity.js +13 -2
- package/lib/cjs/components/FeedObject/FeedObject.js +1 -1
- package/lib/esm/components/CommentObject/CommentObject.d.ts +6 -0
- package/lib/esm/components/CommentObject/CommentObject.js +4 -4
- package/lib/esm/components/Editor/nodes/ImageNode.d.ts +2 -6
- package/lib/esm/components/Editor/nodes/ImageNode.js +14 -23
- package/lib/esm/components/Editor/plugins/ImagePlugin.js +11 -16
- package/lib/esm/components/Editor/plugins/OnChangePlugin.js +0 -54
- package/lib/esm/components/FeedObject/Activities/Activities.js +1 -1
- package/lib/esm/components/FeedObject/Activities/RelevantActivities/CommentActivity/CommentActivity.js +14 -3
- package/lib/esm/components/FeedObject/FeedObject.js +1 -1
- package/lib/umd/518.js +2 -0
- package/lib/umd/{53.js.LICENSE.txt → 518.js.LICENSE.txt} +0 -9
- package/lib/umd/react-ui.js +1 -1
- package/package.json +2 -2
- package/lib/umd/53.js +0 -2
|
@@ -1,60 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { OnChangePlugin as LexicalOnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
|
|
3
|
-
import { ImageNode } from '../nodes/ImageNode';
|
|
4
|
-
import { MentionNode } from '../nodes/MentionNode';
|
|
5
|
-
import { HeadingNode, QuoteNode } from '@lexical/rich-text';
|
|
6
|
-
import { AutoLinkNode, LinkNode } from '@lexical/link';
|
|
7
|
-
import { CodeNode } from '@lexical/code';
|
|
8
3
|
import { $generateHtmlFromNodes } from '@lexical/html';
|
|
9
|
-
const IS_BOLD = 1;
|
|
10
|
-
const IS_ITALIC = 2;
|
|
11
|
-
const convertText = (node) => {
|
|
12
|
-
if (node.getFormat() === IS_BOLD) {
|
|
13
|
-
return `<strong>${node.__text}</strong>`;
|
|
14
|
-
}
|
|
15
|
-
else if (node.getFormat() === IS_ITALIC) {
|
|
16
|
-
return `<em>${node.__text}</em>`;
|
|
17
|
-
}
|
|
18
|
-
return `<span>${node.__text}</span>`;
|
|
19
|
-
};
|
|
20
|
-
const convertNode = (node, children) => {
|
|
21
|
-
switch (node.getType()) {
|
|
22
|
-
case ImageNode.getType():
|
|
23
|
-
return `<img src="${node.__src}" alt="${node.__altText}" width="${node.__width}" height="${node.__height}" style="max-width: ${node.__maxWidth}px;" />`;
|
|
24
|
-
case MentionNode.getType():
|
|
25
|
-
return `<mention id="${node.__user.id}" ext-id="${node.__user.ext_id}">@${node.__user.username}</mention>`;
|
|
26
|
-
case AutoLinkNode.getType():
|
|
27
|
-
case LinkNode.getType():
|
|
28
|
-
return `<a href="${node.__url}">${node.__url}</a>`;
|
|
29
|
-
case 'list':
|
|
30
|
-
return `<${node.__tag}>${children}</${node.__tag}>`;
|
|
31
|
-
case 'listitem':
|
|
32
|
-
return `<li>${node.__value}</li>`;
|
|
33
|
-
case QuoteNode.getType():
|
|
34
|
-
return `<blockquote>${children}</blockquote>`;
|
|
35
|
-
case CodeNode.getType():
|
|
36
|
-
return `<pre>${children}</pre>`;
|
|
37
|
-
case 'linebreak':
|
|
38
|
-
return `<br/>`;
|
|
39
|
-
case 'text':
|
|
40
|
-
return convertText(node);
|
|
41
|
-
case HeadingNode.getType():
|
|
42
|
-
return `<${node.__tag}>${children}</${node.__tag}>`;
|
|
43
|
-
case 'paragraph':
|
|
44
|
-
return `<p>${children ? children : '<br/>'}</p>`;
|
|
45
|
-
case 'root':
|
|
46
|
-
return children;
|
|
47
|
-
default:
|
|
48
|
-
return '';
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
const $toHtml = (node) => {
|
|
52
|
-
let html = '';
|
|
53
|
-
// Create html for child nodes
|
|
54
|
-
node.getChildren && node.getChildren().map((child) => (html += $toHtml(child)));
|
|
55
|
-
// Return new html
|
|
56
|
-
return convertNode(node, html);
|
|
57
|
-
};
|
|
58
4
|
const OnChangePlugin = (props) => {
|
|
59
5
|
// PROPS
|
|
60
6
|
const { onChange } = props;
|
|
@@ -88,7 +88,7 @@ export default function Activities(inProps) {
|
|
|
88
88
|
* Render comments of feedObject
|
|
89
89
|
*/
|
|
90
90
|
function renderComments() {
|
|
91
|
-
return (React.createElement(React.Fragment, null, (commentsObject.feedObject.comment_count > 0 || comments.length > 0) && (React.createElement(CommentsObject, Object.assign({ feedObject: commentsObject.feedObject, comments: commentsObject.comments, startComments: comments, next: commentsObject.next, isLoadingNext: commentsObject.isLoadingNext, handleNext: handleNext, totalLoadedComments: commentsObject.comments.length + comments.length, totalComments: commentsObject.feedObject.comment_count, hideAdvertising: true }, CommentsObjectProps, { cacheStrategy: cacheStrategy, CommentsObjectSkeletonProps: { count: skeletonsCount }, CommentComponentProps: Object.assign(Object.assign(Object.assign({
|
|
91
|
+
return (React.createElement(React.Fragment, null, (commentsObject.feedObject.comment_count > 0 || comments.length > 0) && (React.createElement(CommentsObject, Object.assign({ feedObject: commentsObject.feedObject, comments: commentsObject.comments, startComments: comments, next: commentsObject.next, isLoadingNext: commentsObject.isLoadingNext, handleNext: handleNext, totalLoadedComments: commentsObject.comments.length + comments.length, totalComments: commentsObject.feedObject.comment_count, hideAdvertising: true }, CommentsObjectProps, { cacheStrategy: cacheStrategy, CommentsObjectSkeletonProps: { count: skeletonsCount }, CommentComponentProps: Object.assign(Object.assign(Object.assign(Object.assign({}, (CommentsObjectProps.CommentComponentProps ? CommentsObjectProps.CommentComponentProps : {})), { truncateContent: true }), CommentComponentProps), { cacheStrategy }), inPlaceLoadMoreContents: false })))));
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* Renders root object
|
|
@@ -3,12 +3,14 @@ import React, { useState } from 'react';
|
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
4
|
import { Avatar } from '@mui/material';
|
|
5
5
|
import { Link, SCRoutes, useSCRouting } from '@selfcommunity/react-core';
|
|
6
|
-
import { defineMessages, useIntl } from 'react-intl';
|
|
6
|
+
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
7
7
|
import DateTimeAgo from '../../../../../shared/DateTimeAgo';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import { useThemeProps } from '@mui/system';
|
|
10
10
|
import BaseItem from '../../../../../shared/BaseItem';
|
|
11
11
|
import UserDeletedSnackBar from '../../../../../shared/UserDeletedSnackBar';
|
|
12
|
+
import { getContributionHtml, getRouteData } from '../../../../../utils/contribution';
|
|
13
|
+
import { MAX_SUMMARY_LENGTH } from '../../../../../constants/Feed';
|
|
12
14
|
const messages = defineMessages({
|
|
13
15
|
comment: {
|
|
14
16
|
id: 'ui.feedObject.relevantActivities.comment',
|
|
@@ -19,7 +21,8 @@ const PREFIX = 'SCCommentRelevantActivity';
|
|
|
19
21
|
const classes = {
|
|
20
22
|
root: `${PREFIX}-root`,
|
|
21
23
|
avatar: `${PREFIX}-avatar`,
|
|
22
|
-
username: `${PREFIX}-username
|
|
24
|
+
username: `${PREFIX}-username`,
|
|
25
|
+
showMoreContent: `${PREFIX}-show-more-content`
|
|
23
26
|
};
|
|
24
27
|
const Root = styled(BaseItem, {
|
|
25
28
|
name: PREFIX,
|
|
@@ -53,11 +56,19 @@ export default function CommentRelevantActivity(inProps) {
|
|
|
53
56
|
// INTL
|
|
54
57
|
const intl = useIntl();
|
|
55
58
|
// RENDER
|
|
59
|
+
const summaryHtmlTruncated = 'summary_truncated' in activityObject.comment
|
|
60
|
+
? activityObject.comment.summary_truncated
|
|
61
|
+
: activityObject.comment.html.length >= MAX_SUMMARY_LENGTH;
|
|
62
|
+
const commentHtml = 'summary_html' in activityObject.comment ? activityObject.comment.summary_html : activityObject.comment.summary;
|
|
63
|
+
const summaryHtml = getContributionHtml(commentHtml, scRoutingContext.url);
|
|
56
64
|
return (React.createElement(React.Fragment, null,
|
|
57
65
|
React.createElement(Root, Object.assign({}, rest, { className: classNames(classes.root, className), image: React.createElement(Link, Object.assign({}, (!activityObject.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, activityObject.author) }), { onClick: activityObject.author.deleted ? () => setOpenAlert(true) : null }),
|
|
58
66
|
React.createElement(Avatar, { alt: activityObject.author.username, variant: "circular", src: activityObject.author.avatar, className: classes.avatar })), primary: React.createElement(React.Fragment, null, intl.formatMessage(messages.comment, {
|
|
59
67
|
username: (React.createElement(Link, Object.assign({}, (!activityObject.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, activityObject.author) }), { onClick: activityObject.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }), activityObject.author.username)),
|
|
60
|
-
comment:
|
|
68
|
+
comment: (React.createElement(React.Fragment, null,
|
|
69
|
+
summaryHtml,
|
|
70
|
+
React.createElement(Link, { to: scRoutingContext.url(SCRoutes.COMMENT_ROUTE_NAME, getRouteData(activityObject.comment)), className: classes.showMoreContent },
|
|
71
|
+
React.createElement(FormattedMessage, { id: "ui.commentObject.showMore", defaultMessage: "ui.commentObject.showMore" }))))
|
|
61
72
|
})), secondary: React.createElement(DateTimeAgo, { date: activityObject.active_at }) })),
|
|
62
73
|
openAlert && React.createElement(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })));
|
|
63
74
|
}
|
|
@@ -459,7 +459,7 @@ export default function FeedObject(inProps) {
|
|
|
459
459
|
template === SCFeedObjectTemplateType.PREVIEW && (obj.comment_count > 0 || (feedObjectActivities && feedObjectActivities.length > 0)) && (React.createElement(Collapse, { in: expandedActivities, timeout: "auto", classes: { root: classes.activitiesSection } },
|
|
460
460
|
React.createElement(CardContent, { className: classes.activitiesContent },
|
|
461
461
|
React.createElement(Activities, Object.assign({ feedObject: obj, key: selectedActivities, feedObjectActivities: feedObjectActivities, activitiesType: selectedActivities, onSetSelectedActivities: handleSelectedActivities, comments: comments, CommentsObjectProps: {
|
|
462
|
-
CommentComponentProps: Object.assign({ onDelete: handleDeleteComment, truncateContent: true }, CommentComponentProps),
|
|
462
|
+
CommentComponentProps: Object.assign({ onDelete: handleDeleteComment, truncateContent: true, CommentsObjectComponentProps: { inPlaceLoadMoreContents: false } }, CommentComponentProps),
|
|
463
463
|
CommentObjectSkeletonProps: CommentObjectSkeletonProps
|
|
464
464
|
}, cacheStrategy: cacheStrategy }, ActivitiesProps))))),
|
|
465
465
|
composerOpen && (React.createElement(Composer, { open: composerOpen, feedObject: obj, onClose: handleToggleEdit, onSuccess: handleEditSuccess, maxWidth: "sm", fullWidth: true, scroll: "body" })))) : (React.createElement(FeedObjectSkeleton, Object.assign({ template: template }, FeedObjectSkeletonProps)))));
|