Skip to content

Adding mentions feature to sparks. #12

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
79 changes: 69 additions & 10 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"next-share": "^0.6.0",
"next-themes": "^0.0.15",
"nookies": "^2.5.2",
"primereact": "^10.0.3",
"react": "^17.0.2",
"react-3d-earth": "^1.0.5",
"react-awesome-reveal": "^4.2.3",
Expand Down
6 changes: 5 additions & 1 deletion src/components/common/cards/PostCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import extractUrls from 'extract-urls';
import TagPostType from 'components/common/tags/TagPostType';
import Icon from '../elements/Icon';
import PollCard from './PollCard';
import MentionsSpan from '../elements/MentionsSpan';

const sparkCharCount = 250;

Expand Down Expand Up @@ -112,6 +113,9 @@ const Post = (props) => {
className: 'text-sm sm:text-base font-normal',
},
},
span: {
component: MentionsSpan,
},
},
}}
>
Expand Down Expand Up @@ -229,7 +233,7 @@ const Post = (props) => {
<ModalDialog
show={showPost}
setShow={setShowPost}
title={`${props.project.projectName}...`}
title={`${props.project.projectName.replace(/\[|\]/g, '')}...`}
dimensions={'sm:max-w-screen-md'}
>
<div>
Expand Down
40 changes: 32 additions & 8 deletions src/components/common/elements/MarkdownContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,43 @@ const MarkdownPreview = dynamic(
);
import rehypeHighlight from 'rehype-highlight';
import { useTheme } from 'next-themes';
import Markdown from 'markdown-to-jsx';
import MentionsSpan from './MentionsSpan';
import CodeBlock from './CodeBlock';

const MarkdownContent = ({ content }) => {
const { systemTheme, theme } = useTheme();
const currentTheme = theme === 'system' ? systemTheme : theme;
// const { systemTheme, theme } = useTheme();
// const currentTheme = theme === 'system' ? systemTheme : theme;

return (
<MarkdownPreview
source={content}
remarkPlugins={[rehypeHighlight, { detect: true }]}
wrapperElement={{
'data-color-mode': currentTheme,
// <MarkdownPreview
// source={content}
// remarkPlugins={[rehypeHighlight, { detect: true }]}
// wrapperElement={{
// 'data-color-mode': currentTheme,
// }}

// />
<Markdown
options={{
overrides: {
pre: {
component: CodeBlock,
},
span: {
component: MentionsSpan,
},
a: {
props: {
className: 'break-all text-left',
target: '_blank',
},
},
},
}}
/>
>
{content}
</Markdown>
);
};

Expand Down
Loading