From 9909f1a1c1e9c959489d610281d0d593fe439e38 Mon Sep 17 00:00:00 2001 From: hole-thu Date: Tue, 31 May 2022 23:22:15 +0800 Subject: [PATCH] feat: edit local attention --- src/Flows.css | 8 ++++- src/Flows.js | 85 ++++++++++++++++++++++++++++++--------------------- 2 files changed, 58 insertions(+), 35 deletions(-) diff --git a/src/Flows.css b/src/Flows.css index 59696f5..7e4df8b 100644 --- a/src/Flows.css +++ b/src/Flows.css @@ -334,7 +334,13 @@ } .export-btn { - float: right; + position: absolute; + top: -25px; + right: 0; +} + +.flow-container { + position: relative; } .flow-submode-choice { diff --git a/src/Flows.js b/src/Flows.js index c72f1ef..5021fc4 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -1,4 +1,4 @@ -import React, { PureComponent } from 'react'; +import React, { PureComponent, useState } from 'react'; import copy from 'copy-to-clipboard'; import { ColorPicker } from './color_picker'; import { split_text, PID_RE } from './text_splitter'; @@ -1317,7 +1317,7 @@ class SubFlow extends PureComponent { title: '', data: [], }, - export_text: '', + local_attention_text: null, loading_status: 'done', error_msg: null, }; @@ -1549,49 +1549,38 @@ class SubFlow extends PureComponent { gen_export() { this.setState({ can_export: false, - export_text: - '以下是你关注的洞及摘要,复制保存到本地吧。\n\n' + - this.state.chunks.data - .map( - (p) => - `#${p.pid}: ${this.trunc_string( - p.text.replaceAll('\n', ' '), - 50, - )}`, - ) - .join('\n\n'), + local_attention_text: JSON.parse(localStorage['saved_attentions'] || '[]') + .map((pid) => `#${pid}`) + .join(' '), }); } render() { const should_deletion_detect = localStorage['DELETION_DETECT'] === 'on'; + const { mode, chunks, local_attention_text, search_param } = this.state; return (
- {this.state.mode === 'attention_finished' && this.props.submode == 0 && ( - - )} + {mode === 'attention' && + this.props.submode === 1 && + local_attention_text === null && ( + + )} - {this.state.export_text && ( -
-