Skip to content

Commit

Permalink
feat: add highlight support
Browse files Browse the repository at this point in the history
  • Loading branch information
EINDEX committed Feb 25, 2024
1 parent e4d5617 commit d8e6a10
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/pages/content/QuickCapture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import scssStyles from './index.module.scss';

const logseqCopilotPopupId = 'logseq-copilot-popup';
export const zIndex = '2147483647';
const highlights = CSS.highlights;

const QuickCapture = () => {
const [position, setPostion] = useState({
Expand All @@ -15,10 +16,19 @@ const QuickCapture = () => {
});
const [show, setShow] = useState(false);

const setHighlight = (range: Range) => {
if(!highlights.has("copilot-highlight")) {
highlights.set('copilot-highlight', new Highlight())
}
const highlight = highlights.get('copilot-highlight');
highlight.add(range);
}

const capture = () => {
const selection = getSelection();
if (selection !== null) {
const range = selection.getRangeAt(0);
setHighlight(range);
const clonedSelection = range.cloneContents();
const turndownService = buildTurndownService();
selection.empty();
Expand Down

0 comments on commit d8e6a10

Please sign in to comment.