mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(frontend): resolve Nlu text selection bug
This commit is contained in:
parent
0e3187c844
commit
09a05a379e
@ -25,18 +25,18 @@ import {
|
|||||||
|
|
||||||
const SelectableBox = styled(Box)({
|
const SelectableBox = styled(Box)({
|
||||||
position: "relative",
|
position: "relative",
|
||||||
height: "30px",
|
|
||||||
marginBottom: "1rem",
|
marginBottom: "1rem",
|
||||||
"& .highlight, & .editable": {
|
"& .highlight, & .editable": {
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
top: 0,
|
top: 0,
|
||||||
display: "block",
|
display: "block",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
padding: "4px",
|
padding: "0 4px",
|
||||||
|
lineHeight: 1.5,
|
||||||
},
|
},
|
||||||
"& .editable": {
|
"& .editable": {
|
||||||
|
position: "relative",
|
||||||
backgroundColor: "transparent",
|
backgroundColor: "transparent",
|
||||||
padding: "0px 4px",
|
|
||||||
color: "#000",
|
color: "#000",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -169,10 +169,10 @@ const Selectable: FC<SelectableProps> = ({
|
|||||||
) {
|
) {
|
||||||
const inputContainer = editableRef.current;
|
const inputContainer = editableRef.current;
|
||||||
let substring: string = "";
|
let substring: string = "";
|
||||||
let input: HTMLInputElement | null = null;
|
let input: HTMLTextAreaElement | null = null;
|
||||||
|
|
||||||
if (inputContainer) {
|
if (inputContainer) {
|
||||||
input = inputContainer.querySelector("input");
|
input = inputContainer.querySelector("textarea");
|
||||||
|
|
||||||
if (
|
if (
|
||||||
input &&
|
input &&
|
||||||
@ -267,6 +267,7 @@ const Selectable: FC<SelectableProps> = ({
|
|||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<Input
|
<Input
|
||||||
|
multiline
|
||||||
ref={editableRef}
|
ref={editableRef}
|
||||||
className="editable"
|
className="editable"
|
||||||
fullWidth
|
fullWidth
|
||||||
|
@ -210,12 +210,13 @@ const NlpDatasetSample: FC<NlpDatasetSampleProps> = ({
|
|||||||
keywordEntities={keywordEntities}
|
keywordEntities={keywordEntities}
|
||||||
patternEntities={patternEntities}
|
patternEntities={patternEntities}
|
||||||
placeholder={t("placeholder.nlp_sample_text")}
|
placeholder={t("placeholder.nlp_sample_text")}
|
||||||
onSelect={(selection, start, end) => {
|
onSelect={(newSelection, start, end) => {
|
||||||
setSelection({
|
newSelection !== selection?.value &&
|
||||||
value: selection,
|
setSelection({
|
||||||
start,
|
value: newSelection,
|
||||||
end,
|
start,
|
||||||
});
|
end,
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
onChange={({ text, entities }) => {
|
onChange={({ text, entities }) => {
|
||||||
debounceSetText(text);
|
debounceSetText(text);
|
||||||
@ -322,9 +323,7 @@ const NlpDatasetSample: FC<NlpDatasetSampleProps> = ({
|
|||||||
</ContentItem>
|
</ContentItem>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
{
|
{/* Keyword entities */}
|
||||||
/* Keyword entities */
|
|
||||||
}
|
|
||||||
<Box display="flex" flexDirection="column">
|
<Box display="flex" flexDirection="column">
|
||||||
{keywordEntities.map((keywordEntity, index) => (
|
{keywordEntities.map((keywordEntity, index) => (
|
||||||
<ContentItem
|
<ContentItem
|
||||||
|
Loading…
Reference in New Issue
Block a user