-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: highlight text when selected in a demo page
- Loading branch information
1 parent
572c4c2
commit d4e03fd
Showing
3 changed files
with
1,967 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,36 @@ | ||
import { createApp } from "vue"; | ||
import ElementPlus from "element-plus"; | ||
import Popup from "./Popup.vue"; | ||
import "element-plus/lib/theme-chalk/index.css"; | ||
import { createApp } from 'vue' | ||
import ElementPlus from 'element-plus' | ||
import Popup from './Popup.vue' | ||
import 'element-plus/lib/theme-chalk/index.css' | ||
|
||
const MOUNT_EL_ID = "attonex_clipper"; | ||
import { demoHtml } from './parser/demo' | ||
import { getSelecetdTextRects, highlightRects } from './parser/text-rect' | ||
|
||
let mountEl = document.getElementById(MOUNT_EL_ID); | ||
const MOUNT_EL_ID = 'attonex_clipper' | ||
|
||
let mountEl = document.getElementById(MOUNT_EL_ID) | ||
if (mountEl) { | ||
mountEl.innerHTML = ""; | ||
mountEl.innerHTML = '' | ||
} | ||
mountEl = document.createElement("div"); | ||
mountEl.setAttribute("id", MOUNT_EL_ID); | ||
document.body.appendChild(mountEl); | ||
const vm = createApp(Popup).use(ElementPlus).mount(mountEl); | ||
mountEl = document.createElement('div') | ||
mountEl.setAttribute('id', MOUNT_EL_ID) | ||
document.body.appendChild(mountEl) | ||
const vm = createApp(Popup) | ||
.use(ElementPlus) | ||
.mount(mountEl) | ||
|
||
chrome.runtime.onMessage.addListener((message) => { | ||
if (message.toggleVisible) { | ||
(vm as any).visible = !(vm as any).visible; | ||
} | ||
}); | ||
if (message.toggleVisible) { | ||
;(vm as any).visible = !(vm as any).visible | ||
} | ||
}) | ||
|
||
const demoPageDiv = document.createElement('div') | ||
demoPageDiv.innerHTML = demoHtml; | ||
document.body.appendChild(demoPageDiv) | ||
|
||
document.addEventListener('mouseup', () => { | ||
console.log('mouse up') | ||
const rects = getSelecetdTextRects() | ||
highlightRects(rects); | ||
}) |
Oops, something went wrong.