Skip to content

Commit

Permalink
hightlight selected line
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Jeanneney committed Aug 2, 2024
1 parent 6b57f2b commit e90bc4c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function AnnotationCreationTooltipMenu(props: {
color: theme.colors.default.hoveredTextColor,
padding: '2px 4px',
borderRadius: '3px',
whiteSpace: 'pre-wrap', // Preserve line breaks
whiteSpace: 'pre-wrap',
},
checkboxContainer: {
alignSelf: 'flex-start',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function DocumentLine(props: {
const textColor = isLineHighlighted() ? 'textPrimary' : 'textSecondary';

return (
<tr id={`line${props.line}`}>
<tr id={`line${props.line}`} style={props.isHighlighted ? styles.selectedLine : {}}>
<td style={styles.lineNumberCell} onClick={() => props.onLineClick(props.line)}>
<Text variant="body2" color={props.isHighlighted ? 'textPrimary' : 'textSecondary'}>
{props.line ?? '[…]'}
Expand Down Expand Up @@ -73,5 +73,8 @@ function buildStyles(theme: customThemeType) {
lineTextCell: {
overflowWrap: 'anywhere',
},
selectedLine: {
backgroundColor: theme.colors.default.background,
},
} as const;
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ function DocumentText(props: propsType): ReactElement {
}

function getValidSelection(selection: Selection | null) {
console.log(selection?.toString());
if (!selection) {
return [];
}
Expand All @@ -77,8 +76,6 @@ function DocumentText(props: propsType): ReactElement {
}
if (anchorNodeValue === focusNodeValue) {
//cette condition entraine un bug si on cherche a créer une annotation sur plusieurs lignes qui commence et qui termine par le même mot, en effet la condition sera vraie alors qu'il sagirat d'un anchor et d'un focus différent
console.log('anchorNodeValue === focusNodeValue');
console.log([{ text: selectionText.trim(), index: computeSelectedTextIndex(selection) }]);
return [{ text: selectionText.trim(), index: computeSelectedTextIndex(selection) }];
}
return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@ function DocumentViewer(props: { splittedTextByLine: splittedTextByLineType }):
const textBetweenLines = getTextBetweenLines(selectedLines[0], selectedLines[1]);
setSelectedParagraphText(textBetweenLines.text);
setParagraphStartIndex(textBetweenLines.index);
setTooltipMenuOriginPosition({ x: window.innerWidth / 2, y: window.innerHeight / 2 });
setTooltipMenuOriginPosition({ x: window.innerWidth / 2, y: window.innerHeight / 4 });
} else {
setTooltipMenuOriginPosition(undefined);
}
}, [selectedLines]);

const getTextBetweenLines = (startLine: number, endLine: number) => {
const lines = props.splittedTextByLine.filter((line) => line.line >= startLine && line.line <= endLine);
console.log(lines);

// Delete empty lines at the beggining
let startIndex = 0;
Expand Down

0 comments on commit e90bc4c

Please sign in to comment.