Skip to content

Commit d8e6a10

Browse files
committed
feat: add highlight support
1 parent e4d5617 commit d8e6a10

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/pages/content/QuickCapture.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import scssStyles from './index.module.scss';
77

88
const logseqCopilotPopupId = 'logseq-copilot-popup';
99
export const zIndex = '2147483647';
10+
const highlights = CSS.highlights;
1011

1112
const QuickCapture = () => {
1213
const [position, setPostion] = useState({
@@ -15,10 +16,19 @@ const QuickCapture = () => {
1516
});
1617
const [show, setShow] = useState(false);
1718

19+
const setHighlight = (range: Range) => {
20+
if(!highlights.has("copilot-highlight")) {
21+
highlights.set('copilot-highlight', new Highlight())
22+
}
23+
const highlight = highlights.get('copilot-highlight');
24+
highlight.add(range);
25+
}
26+
1827
const capture = () => {
1928
const selection = getSelection();
2029
if (selection !== null) {
2130
const range = selection.getRangeAt(0);
31+
setHighlight(range);
2232
const clonedSelection = range.cloneContents();
2333
const turndownService = buildTurndownService();
2434
selection.empty();

0 commit comments

Comments
 (0)