Skip to content

Commit

Permalink
apply feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcho committed Dec 5, 2024
1 parent 117fd03 commit 3147a49
Show file tree
Hide file tree
Showing 5 changed files with 306 additions and 267 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@wyw-in-js/babel-preset": "^0.5.3",
"@wyw-in-js/vite": "^0.5.3",
"date-fns": "^3.6.0",
"dompurify": "^3.2.2",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.6.1",
Expand Down
21 changes: 16 additions & 5 deletions src/components/TokensBody.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import DOMPurify from 'dompurify';
import Markdown from 'markdown-to-jsx';
import styled from 'styled-components';

Expand All @@ -6,7 +7,8 @@ import SourceContainer, { Source } from './SourceContainer';
import { CodeBlock } from './ui/CodeBlock';
import { useConstantState } from '../context/ConstantContext';
import { Token, TokenType } from '../utils';
import './markdown.css';

import './markdown.scss';

type TokensBodyProps = {
tokens: Token[];
Expand Down Expand Up @@ -46,28 +48,37 @@ export default function TokensBody({ tokens, sources }: TokensBodyProps) {
{tokens.map((token: Token, i) => {
// Normal text part of the message.
if (token.type === TokenType.string) {
console.log('## token: ', token.value);
return (
<div key={i} className="markdown">
<div key={i} className="widget-markdown">
<Markdown
options={{
sanitizer: (value: string) => {
return DOMPurify.sanitize(value);
},
overrides: {
// Note that this is to remove text-align: left by the library.
// Note that this is to remove text-align: right by the library.
td: {
component: ({ children, ...props }) => (
<td {...props} style={null}>
{children}
</td>
),
},
// Note that this is to remove text-align: left by the library.
// Note that this is to remove text-align: right by the library.
th: {
component: ({ children, ...props }) => (
<th {...props} style={null}>
{children}
</th>
),
},
a: {
component: ({ children, ...props }) => (
<a {...props} target='_blank'>
{children}
</a>
),
},
},
}}
>
Expand Down
261 changes: 0 additions & 261 deletions src/components/markdown.css

This file was deleted.

Loading

0 comments on commit 3147a49

Please sign in to comment.