diff --git a/src/Common.js b/src/Common.js index cf2f9cb..daf29ac 100644 --- a/src/Common.js +++ b/src/Common.js @@ -9,6 +9,7 @@ import { URL_RE, PID_RE, NICKNAME_RE, + TAG_RE, split_text, } from './text_splitter'; @@ -67,6 +68,7 @@ function normalize_url(url) { return /^https?:\/\//.test(url) ? url : 'http://' + url; } +/* export class HighlightedText extends PureComponent { render() { return ( @@ -109,6 +111,7 @@ export class HighlightedText extends PureComponent { ); } } +*/ // props: text, show_pid, color_picker export class HighlightedMarkdown extends Component { @@ -116,12 +119,6 @@ export class HighlightedMarkdown extends Component { const props = this.props; const processDefs = new HtmlToReact.ProcessNodeDefinitions(React); const processInstructions = [ - { - shouldProcessNode: (node) => node.name === 'img', // disable images - processNode(node, children, index) { - return
[图片]
; - }, - }, { shouldProcessNode: (node) => /^h[123456]$/.test(node.name), processNode(node, children, index) { @@ -131,6 +128,26 @@ export class HighlightedMarkdown extends Component { return {children}; }, }, + { + shouldProcessNode: (node) => node.name === 'img', + processNode(node, index) { + return ( + + {node.alt} + + ); + }, + }, { shouldProcessNode: (node) => node.name === 'a', processNode(node, children, index) { @@ -164,7 +181,7 @@ export class HighlightedMarkdown extends Component { ['url', URL_RE], ['pid', PID_RE], ['nickname', NICKNAME_RE], - //TODO: tag + ['tag', TAG_RE], ]); return ( @@ -202,6 +219,12 @@ export class HighlightedMarkdown extends Component { ) : rule === 'search' ? ( {p} + ) : rule === 'tag' ? ( + + {p} + ) : ( p )} diff --git a/src/Flows.css b/src/Flows.css index 0e1bcf2..45a5b23 100644 --- a/src/Flows.css +++ b/src/Flows.css @@ -193,6 +193,17 @@ overflow-x: auto; } +.box-content img { + max-width: 100%; + max-height: 2000px; + display: block; + margin: 0 auto; +} + +.left-container .box-content img { + max-height: 500px; +} + .left-container .box-content { max-height: calc(100vh + 15em); overflow-y: hidden; diff --git a/src/Flows.js b/src/Flows.js index ffc8f76..5b4b47d 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -7,6 +7,7 @@ import { PID_RE, URL_RE, URL_PID_RE, + TAG_RE, } from './text_splitter'; import { format_time, @@ -665,7 +666,7 @@ class FlowItemRow extends PureComponent { constructor(props) { super(props); this.needFold = props.info.cw && - (props.search_param === '热榜' || !props.search_param) && + !props.search_param && (window.config.whitelist_cw.indexOf('*')==-1 && window.config.whitelist_cw.indexOf(props.info.cw)==-1) && props.mode !== 'attention' && props.mode !== 'attention_finished'; this.state = { @@ -770,6 +771,7 @@ class FlowItemRow extends PureComponent { ['url', URL_RE], ['pid', PID_RE], ['nickname', NICKNAME_RE], + ['tag', TAG_RE], ]; if (this.props.search_param) { hl_rules.push([ @@ -781,6 +783,8 @@ class FlowItemRow extends PureComponent { } let parts = split_text(this.state.info.text, hl_rules); + //console.log('hl:', parts,this.state.info.pid); + let quote_id = null; if (!this.props.is_quote) for (let [mode, content] of parts) { diff --git a/src/Title.js b/src/Title.js index 99b6205..983e9f2 100644 --- a/src/Title.js +++ b/src/Title.js @@ -35,6 +35,24 @@ class ControlBar extends PureComponent { }, ); } + + window.addEventListener("hashchange", + () => { + let text = decodeURIComponent(window.location.hash).substr(1); + if(text && text[0]!='#') { + console.log('search', text); + this.setState( + { + search_text: text, + }, + () => { + this.on_keypress({ key: 'Enter' }); + }, + ); + } + }, + false + ); } on_change(event) { @@ -116,9 +134,8 @@ class ControlBar extends PureComponent { diff --git a/src/UserAction.js b/src/UserAction.js index 2a60da9..e5828d4 100644 --- a/src/UserAction.js +++ b/src/UserAction.js @@ -541,6 +541,7 @@ export class PostForm extends Component { on_submit(event) { if (event) event.preventDefault(); if (this.state.loading_status === 'loading') return; + /* if (this.img_ref.current.files.length) { this.setState({ loading_status: 'processing', @@ -555,7 +556,8 @@ export class PostForm extends Component { .catch((e) => { alert(e); }); - } else { + } else */ + { this.setState({ loading_status: 'loading', }); @@ -573,6 +575,7 @@ export class PostForm extends Component { return (
+ {/* + */} {this.state.preview ? (