File tree Expand file tree Collapse file tree 6 files changed +48
-14
lines changed
Expand file tree Collapse file tree 6 files changed +48
-14
lines changed Original file line number Diff line number Diff line change 11{
2- "version" : " 0.0.11 " ,
2+ "version" : " 0.0.13 " ,
33 "description" : " a apitable widget" ,
44 "engines" : {
55 "node" : " >=8.x"
Original file line number Diff line number Diff line change 11import React , { FC } from 'react' ;
2- import ReactMarkdown from 'react-markdown' ;
2+ import { StyleSheetManager } from 'styled-components' ;
3+ import { MarkdownStyled } from './styled' ;
4+ import { IContentWindow } from '../../render_base' ;
35
46interface IMarkdownProps {
57 source : string ;
8+ window : IContentWindow ;
69}
710
811export const Markdown : FC < IMarkdownProps > = ( props ) => {
9- const { source } = props ;
12+ const { source, window } = props ;
1013
1114 const LinkRenderer = ( props ) => {
1215 return (
@@ -17,8 +20,14 @@ export const Markdown: FC<IMarkdownProps> = (props) => {
1720 }
1821
1922 return (
20- < ReactMarkdown components = { { a : LinkRenderer } } >
21- { source }
22- </ ReactMarkdown >
23+ < StyleSheetManager
24+ target = { window . document . head }
25+ >
26+ < MarkdownStyled
27+ components = { { a : LinkRenderer } }
28+ >
29+ { source }
30+ </ MarkdownStyled >
31+ </ StyleSheetManager >
2332 ) ;
2433} ;
Original file line number Diff line number Diff line change 1+ import styled , { css } from 'styled-components' ;
2+ import ReactMarkdown from 'react-markdown' ;
3+ import { applyDefaultTheme } from '../utils' ;
4+
5+ export const MarkdownStyled = styled ( ReactMarkdown ) . attrs ( applyDefaultTheme ) `
6+ ${ props => {
7+ const { textCommonPrimary } = props . theme . color ;
8+
9+ return css `
10+ color : ${ textCommonPrimary } ;
11+ ` ;
12+ } }
13+ ` ;
Original file line number Diff line number Diff line change 1+ import styled , { css } from 'styled-components' ;
2+ import { applyDefaultTheme } from '../utils' ;
3+
4+ export const TextContainer = styled . div . attrs ( applyDefaultTheme ) `
5+ ${ props => {
6+ const { textCommonPrimary } = props . theme . color ;
7+
8+ return css `
9+ color : ${ textCommonPrimary } ;
10+ ` ;
11+ } }
12+ ` ;
Original file line number Diff line number Diff line change 11import React , { FC } from 'react' ;
2- import { useTheme } from '@apitable/components' ;
32import { StyleSheetManager } from 'styled-components' ;
3+ import { TextContainer } from './styled' ;
4+ import { IContentWindow } from '../../render_base' ;
45
56interface ITextProps {
67 name : string ;
8+ window : IContentWindow ;
79}
810
911export const Text : FC < ITextProps > = ( props ) => {
10- const { name } = props ;
11- const { color } = useTheme ( ) ;
12+ const { name, window } = props ;
1213
1314 return (
1415 < StyleSheetManager
1516 target = { window . document . head }
1617 >
17- < div style = { { color : color . textStaticPrimary } } >
18+ < TextContainer >
1819 { name }
19- </ div >
20+ </ TextContainer >
2021 </ StyleSheetManager >
2122 ) ;
2223}
Original file line number Diff line number Diff line change @@ -15,10 +15,9 @@ export class OutputClass extends RenderBase implements Output {
1515 }
1616
1717 public markdown ( source : string ) {
18+ const props = { source } ;
1819 this . renderComponent (
19- < Markdown
20- source = { source }
21- />
20+ < Markdown { ...props as any } />
2221 ) ;
2322 }
2423
You can’t perform that action at this time.
0 commit comments