@nxxxsooo/opencode-annotate 0.0.0-stage → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +86 -0
- package/LICENSE +21 -0
- package/README.md +298 -2
- package/bridge/native-host.mjs +29 -0
- package/bridge/receiver.mjs +77 -0
- package/bridge/wire.mjs +38 -0
- package/browser/UPSTREAM.md +9 -0
- package/browser/capture.js +116 -0
- package/browser/icons/icon-128.png +0 -0
- package/browser/icons/icon-16.png +0 -0
- package/browser/icons/icon-32.png +0 -0
- package/browser/icons/icon-48.png +0 -0
- package/browser/icons/icon.svg +3 -0
- package/browser/inspector.js +125 -0
- package/browser/manifest.json +13 -0
- package/browser/panel.css +114 -0
- package/browser/panel.html +56 -0
- package/browser/panel.mjs +435 -0
- package/browser/protocol.mjs +45 -0
- package/browser/upstream/LICENSE +21 -0
- package/browser/upstream/annotate-1.0.0.js +1910 -0
- package/browser/worker.mjs +183 -0
- package/package.json +65 -4
- package/review.mjs +327 -0
- package/scripts/install-bridge.mjs +27 -0
- package/scripts/install-plugin.mjs +34 -0
- package/scripts/migrate-page-context.mjs +31 -0
- package/targets.mjs +32 -0
- package/theme.mjs +115 -0
- package/tui.ts +66 -0
- package/web-review.mjs +36 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
if (globalThis.__opencodeAnnotate === true) throw new Error("Refresh this page once to update annotation tools. Saved notes will remain.")
|
|
3
|
+
globalThis.__opencodeAnnotate?.dispose()
|
|
4
|
+
if (!["text/html", "application/xhtml+xml"].includes(document.contentType)) throw new Error("Only HTML pages are supported")
|
|
5
|
+
const listeners = new AbortController()
|
|
6
|
+
const on = (target, event, handler, options = {}) => target.addEventListener(event, handler, { ...options, signal: listeners.signal })
|
|
7
|
+
const host = document.createElement("div")
|
|
8
|
+
host.setAttribute("data-opencode-annotate", "")
|
|
9
|
+
host.style.cssText = "all:initial!important;position:fixed!important;inset:0!important;pointer-events:none!important;z-index:2147483647!important"
|
|
10
|
+
const root = host.attachShadow({ mode: "closed" })
|
|
11
|
+
const style = document.createElement("style")
|
|
12
|
+
style.textContent = '.box{position:fixed;pointer-events:none;border:2px solid #c96442;background:#c9644210}.pin{position:fixed;display:grid;place-items:center;background:#c96442;color:#fff;border:2px solid #fff;border-radius:50%;font:600 12px/1 system-ui;width:26px;height:26px;pointer-events:none}'
|
|
13
|
+
root.append(style); document.documentElement.append(host)
|
|
14
|
+
const box = document.createElement("div"); box.className = "box"
|
|
15
|
+
const highlight = document.createElement("div"); highlight.className = "box"
|
|
16
|
+
let highlighted, highlightTimer
|
|
17
|
+
let picking = false, url = location.href, timer, markers = [], active = true
|
|
18
|
+
function send(anchor = null, error = null, modeOnly = false) {
|
|
19
|
+
if (!active) return
|
|
20
|
+
try {
|
|
21
|
+
chrome.runtime.sendMessage({ action: "capture", page: { url: location.href, title: document.title }, anchor, error, picking, modeOnly }).catch(dispose)
|
|
22
|
+
} catch { dispose() }
|
|
23
|
+
}
|
|
24
|
+
function setPicking(value, notify = true) {
|
|
25
|
+
picking = value
|
|
26
|
+
if (picking) root.append(box); else box.remove()
|
|
27
|
+
if (notify) send(null, null, true)
|
|
28
|
+
}
|
|
29
|
+
function selection() {
|
|
30
|
+
if (picking || !active) return
|
|
31
|
+
const selected = getSelection()
|
|
32
|
+
if (!selected?.rangeCount || selected.isCollapsed || selected.anchorNode?.getRootNode() !== document) return
|
|
33
|
+
const range = selected.getRangeAt(0).cloneRange()
|
|
34
|
+
let element = range.commonAncestorContainer
|
|
35
|
+
if (element.nodeType !== 1) element = element.parentElement
|
|
36
|
+
try { send(AnnotateInspector.capture(element, range)) } catch (error) { send(null, error.message) }
|
|
37
|
+
}
|
|
38
|
+
on(document, "selectionchange", () => { clearTimeout(timer); timer = setTimeout(selection, 160) })
|
|
39
|
+
on(document, "pointerup", selection)
|
|
40
|
+
on(document, "mousemove", event => {
|
|
41
|
+
if (!picking) return
|
|
42
|
+
const rect = event.target.getBoundingClientRect()
|
|
43
|
+
box.style.cssText = `left:${rect.x}px;top:${rect.y}px;width:${rect.width}px;height:${rect.height}px`
|
|
44
|
+
}, { capture: true })
|
|
45
|
+
on(document, "pointerdown", event => { if (picking) { event.preventDefault(); event.stopImmediatePropagation() } }, { capture: true })
|
|
46
|
+
on(document, "click", event => {
|
|
47
|
+
if (!picking) return
|
|
48
|
+
event.preventDefault(); event.stopImmediatePropagation()
|
|
49
|
+
// A failed pick must never leave the page trapped in interception mode.
|
|
50
|
+
setPicking(false, false)
|
|
51
|
+
try { send(AnnotateInspector.capture(event.target)) } catch (error) { send(null, error.message) }
|
|
52
|
+
}, { capture: true })
|
|
53
|
+
on(document, "keydown", event => { if (picking && event.key === "Escape") setPicking(false) })
|
|
54
|
+
const onMessage = (message, _sender, respond) => {
|
|
55
|
+
if (message.action === "pick") { setPicking(!picking); respond({ ok: true, picking }) }
|
|
56
|
+
if (message.action === "markers") { markers = message.notes || []; draw(); respond({ ok: true }) }
|
|
57
|
+
if (message.action === "locate") respond({ states: message.anchors.map(locate) })
|
|
58
|
+
if (message.action === "reveal") {
|
|
59
|
+
const state = locate(message.anchor)
|
|
60
|
+
if (state !== "located") {
|
|
61
|
+
respond({ ok: false, error: `This element is ${state}. Your feedback is kept.` })
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
setPicking(false)
|
|
65
|
+
highlighted = document.querySelector(message.anchor.selector)
|
|
66
|
+
highlighted.scrollIntoView({ block: "center", inline: "nearest", behavior: matchMedia("(prefers-reduced-motion: reduce)").matches ? "instant" : "smooth" })
|
|
67
|
+
root.append(highlight); draw()
|
|
68
|
+
clearTimeout(highlightTimer)
|
|
69
|
+
highlightTimer = setTimeout(() => { highlighted = null; highlight.remove() }, 1600)
|
|
70
|
+
respond({ ok: true })
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
chrome.runtime.onMessage.addListener(onMessage)
|
|
74
|
+
function locate(anchor) {
|
|
75
|
+
try {
|
|
76
|
+
const matches = document.querySelectorAll(anchor.selector)
|
|
77
|
+
if (matches.length !== 1) return matches.length ? "ambiguous" : "missing"
|
|
78
|
+
const text = AnnotateInspector.text(matches[0])
|
|
79
|
+
if (!text.includes(anchor.quote)) return "changed"
|
|
80
|
+
if (anchor.type === "text" && text.split(anchor.quote).length > 2) {
|
|
81
|
+
if (!text.includes(`${anchor.prefix || ""}${anchor.quote}${anchor.suffix || ""}`)) return "ambiguous"
|
|
82
|
+
}
|
|
83
|
+
return "located"
|
|
84
|
+
} catch { return "invalid selector" }
|
|
85
|
+
}
|
|
86
|
+
function draw() {
|
|
87
|
+
if (highlighted?.isConnected) {
|
|
88
|
+
const rect = highlighted.getBoundingClientRect()
|
|
89
|
+
highlight.style.cssText = `left:${rect.left}px;top:${rect.top}px;width:${rect.width}px;height:${rect.height}px`
|
|
90
|
+
} else highlight.remove()
|
|
91
|
+
root.querySelectorAll(".pin").forEach(node => node.remove())
|
|
92
|
+
for (const [index, note] of markers.entries()) {
|
|
93
|
+
let matches
|
|
94
|
+
try { matches = document.querySelectorAll(note.anchor.selector) } catch { continue }
|
|
95
|
+
if (matches.length !== 1) continue
|
|
96
|
+
const element = matches[0]
|
|
97
|
+
// A changed or removed quote is an orphan, not another equally named element.
|
|
98
|
+
if (!AnnotateInspector.text(element).includes(note.anchor.quote)) continue
|
|
99
|
+
const rect = element.getBoundingClientRect()
|
|
100
|
+
const pin = document.createElement("span"); pin.className = "pin"; pin.textContent = String(index + 1)
|
|
101
|
+
pin.style.cssText = `left:${rect.left - 10}px;top:${rect.top - 10}px`; root.append(pin)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
on(document, "scroll", draw, { capture: true, passive: true }); on(window, "resize", draw)
|
|
105
|
+
const observer = new MutationObserver(() => { clearTimeout(timer); timer = setTimeout(draw, 160) })
|
|
106
|
+
observer.observe(document.body, { childList: true, subtree: true, characterData: true })
|
|
107
|
+
const routeTimer = setInterval(() => { if (!active) { observer.disconnect(); return } if (url !== location.href) { url = location.href; markers = []; draw(); send() } }, 700)
|
|
108
|
+
function dispose() {
|
|
109
|
+
if (!active) return
|
|
110
|
+
active = false; listeners.abort(); clearInterval(routeTimer); clearTimeout(timer); clearTimeout(highlightTimer); observer.disconnect(); host.remove()
|
|
111
|
+
try { chrome.runtime.onMessage.removeListener(onMessage) } catch { /* previous extension context may already be invalidated */ }
|
|
112
|
+
delete globalThis.__opencodeAnnotate
|
|
113
|
+
}
|
|
114
|
+
globalThis.__opencodeAnnotate = { dispose }
|
|
115
|
+
send()
|
|
116
|
+
})();
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 155 157" width="128" height="128">
|
|
2
|
+
<path d="M58.8282 156.513L62.2248 103.934L18.2055 133.416L0 101.353L47.4158 78.2565L0 55.1599L18.2055 23.0965L62.2248 52.5786L58.8282 0H95.3751L91.8427 52.5786L135.862 23.0965L154.067 55.1599L106.787 78.2565L154.067 101.353L135.862 133.416L91.8427 103.934L95.3751 156.513H58.8282Z" fill="#C96442"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Derived from AsimSayed/annotate-html 1.0.0, MIT. Original bytes and license in upstream/.
|
|
2
|
+
(() => {
|
|
3
|
+
function identifyElement(target, text) {
|
|
4
|
+
const tag = target.tagName.toLowerCase()
|
|
5
|
+
if (target.dataset?.element) return target.dataset.element
|
|
6
|
+
if (["path", "circle", "rect", "line", "g", "svg"].includes(tag)) return "graphic element"
|
|
7
|
+
const label = target.getAttribute("aria-label") || target.getAttribute("alt") || text || ""
|
|
8
|
+
if (tag === "input") return `input "${target.getAttribute("placeholder") || target.getAttribute("type") || "text"}"`
|
|
9
|
+
return label ? `${tag} "${label.slice(0, 60)}"` : tag
|
|
10
|
+
}
|
|
11
|
+
function getComputedSnapshot(el) {
|
|
12
|
+
var s = window.getComputedStyle(el)
|
|
13
|
+
var parts = []
|
|
14
|
+
if (s.color && s.color !== "rgb(0, 0, 0)") parts.push("color: " + s.color)
|
|
15
|
+
var bg = s.backgroundColor
|
|
16
|
+
if (bg && bg !== "rgba(0, 0, 0, 0)" && bg !== "transparent") parts.push("bg: " + bg)
|
|
17
|
+
if (s.fontSize) parts.push("font: " + s.fontSize)
|
|
18
|
+
if (s.fontWeight && s.fontWeight !== "400" && s.fontWeight !== "normal") parts.push("weight: " + s.fontWeight)
|
|
19
|
+
if (s.padding && s.padding !== "0px") parts.push("padding: " + s.padding)
|
|
20
|
+
if (s.margin && s.margin !== "0px") parts.push("margin: " + s.margin)
|
|
21
|
+
var d = s.display
|
|
22
|
+
if (d && d !== "block" && d !== "inline") parts.push("display: " + d)
|
|
23
|
+
if (s.position && s.position !== "static") parts.push("position: " + s.position)
|
|
24
|
+
if (s.borderRadius && s.borderRadius !== "0px") parts.push("radius: " + s.borderRadius)
|
|
25
|
+
return parts.join(", ")
|
|
26
|
+
}
|
|
27
|
+
function getA11yInfo(el) {
|
|
28
|
+
var parts = []
|
|
29
|
+
var role = el.getAttribute("role")
|
|
30
|
+
var ariaLabel = el.getAttribute("aria-label")
|
|
31
|
+
var tabIndex = el.getAttribute("tabindex")
|
|
32
|
+
var ariaHidden = el.getAttribute("aria-hidden")
|
|
33
|
+
if (role) parts.push('role="' + role + '"')
|
|
34
|
+
if (ariaLabel) parts.push('aria-label="' + ariaLabel + '"')
|
|
35
|
+
if (tabIndex) parts.push("tabindex=" + tabIndex)
|
|
36
|
+
if (ariaHidden === "true") parts.push("aria-hidden")
|
|
37
|
+
if (el.matches("a, button, input, select, textarea, [tabindex]")) parts.push("focusable")
|
|
38
|
+
return parts.join(", ")
|
|
39
|
+
}
|
|
40
|
+
function selector(element) {
|
|
41
|
+
const parts = []
|
|
42
|
+
for (let node = element; node?.nodeType === 1; node = node.parentElement) {
|
|
43
|
+
if (node.id && document.querySelectorAll(`#${CSS.escape(node.id)}`).length === 1) { parts.unshift(`#${CSS.escape(node.id)}`); break }
|
|
44
|
+
const siblings = node.parentElement ? [...node.parentElement.children].filter(x => x.localName === node.localName) : [node]
|
|
45
|
+
parts.unshift(`${CSS.escape(node.localName)}:nth-of-type(${siblings.indexOf(node) + 1})`)
|
|
46
|
+
}
|
|
47
|
+
const result = parts.join(" > ")
|
|
48
|
+
if (document.querySelectorAll(result).length !== 1) throw new Error("Element cannot be uniquely located")
|
|
49
|
+
return result
|
|
50
|
+
}
|
|
51
|
+
const editable = 'input,textarea,select,[contenteditable]:not([contenteditable="false"])'
|
|
52
|
+
const excluded = `${editable},script,style,noscript,template,[hidden],[aria-hidden="true"]`
|
|
53
|
+
function textFilter() {
|
|
54
|
+
const cache = new WeakMap()
|
|
55
|
+
return function omitted(element) {
|
|
56
|
+
if (!element) return false
|
|
57
|
+
if (cache.has(element)) return cache.get(element)
|
|
58
|
+
const style = getComputedStyle(element)
|
|
59
|
+
const hidden = element.matches(excluded) || style.display === "none" || style.visibility === "hidden" || style.visibility === "collapse" || style.opacity === "0" || omitted(element.parentElement)
|
|
60
|
+
cache.set(element, hidden)
|
|
61
|
+
return hidden
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function safeText(range, omitted) {
|
|
65
|
+
const root = range.commonAncestorContainer
|
|
66
|
+
const nodes = []
|
|
67
|
+
if (root.nodeType === Node.TEXT_NODE) nodes.push(root)
|
|
68
|
+
else {
|
|
69
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT)
|
|
70
|
+
let node
|
|
71
|
+
while ((node = walker.nextNode())) nodes.push(node)
|
|
72
|
+
}
|
|
73
|
+
const pieces = []
|
|
74
|
+
for (const node of nodes) {
|
|
75
|
+
if (!range.intersectsNode(node) || omitted(node.parentElement)) continue
|
|
76
|
+
const start = node === range.startContainer ? range.startOffset : 0
|
|
77
|
+
const end = node === range.endContainer ? range.endOffset : node.length
|
|
78
|
+
pieces.push(node.data.slice(start, end))
|
|
79
|
+
}
|
|
80
|
+
return pieces.join("")
|
|
81
|
+
}
|
|
82
|
+
function elementText(element, omitted = textFilter()) {
|
|
83
|
+
const control = element.closest(editable)
|
|
84
|
+
if (control) return control.getAttribute("aria-label") || control.getAttribute("placeholder") || `${control.getAttribute("type") || control.localName} control`
|
|
85
|
+
const contents = document.createRange(); contents.selectNodeContents(element)
|
|
86
|
+
return safeText(contents, omitted).trim() || element.getAttribute("aria-label") || element.getAttribute("alt") || element.localName
|
|
87
|
+
}
|
|
88
|
+
function capture(element, range) {
|
|
89
|
+
if (!element || element.getRootNode() !== document) throw new Error("Select content in the main page")
|
|
90
|
+
// Decorative SVGs commonly carry aria-hidden. Point to their visible control instead.
|
|
91
|
+
if (!range && element.closest("[aria-hidden=true]")) element = element.closest('button,a,[role="button"]') || element.parentElement
|
|
92
|
+
if (!element) throw new Error("Choose a visible page element")
|
|
93
|
+
const style = getComputedStyle(element)
|
|
94
|
+
if (element.closest("[hidden],script,style,noscript,template") || style.display === "none" || style.visibility === "hidden") throw new Error("Choose a visible page element")
|
|
95
|
+
if (["iframe", "canvas", "embed", "object"].includes(element.localName)) throw new Error("This content type is unsupported")
|
|
96
|
+
const omitted = textFilter()
|
|
97
|
+
const contents = document.createRange(); contents.selectNodeContents(element)
|
|
98
|
+
const visibleText = safeText(contents, omitted).trim()
|
|
99
|
+
const container = element.closest("p,li,blockquote,pre,td,th,section,article,main") || element
|
|
100
|
+
let quote = "", prefix = "", suffix = ""
|
|
101
|
+
if (range) {
|
|
102
|
+
quote = safeText(range, omitted)
|
|
103
|
+
if (!quote.trim()) throw new Error("Editable values are private. Use Pick an element to annotate the control itself.")
|
|
104
|
+
const before = document.createRange(); before.selectNodeContents(container); before.setEnd(range.startContainer, range.startOffset)
|
|
105
|
+
const after = document.createRange(); after.selectNodeContents(container); after.setStart(range.endContainer, range.endOffset)
|
|
106
|
+
prefix = [...safeText(before, omitted)].slice(-160).join(""); suffix = [...safeText(after, omitted)].slice(0, 160).join("")
|
|
107
|
+
} else {
|
|
108
|
+
element = element.closest(editable) || element
|
|
109
|
+
quote = elementText(element, omitted)
|
|
110
|
+
for (const [sibling, side] of [[element.previousElementSibling, "before"], [element.nextElementSibling, "after"]]) {
|
|
111
|
+
if (!sibling) continue
|
|
112
|
+
const siblingRange = document.createRange(); siblingRange.selectNodeContents(sibling)
|
|
113
|
+
const text = safeText(siblingRange, omitted)
|
|
114
|
+
if (side === "before") prefix = [...text].slice(-160).join(""); else suffix = [...text].slice(0, 160).join("")
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (quote.length > 4000) throw new Error("Choose at most 4000 characters")
|
|
118
|
+
const rect = (range || element).getBoundingClientRect()
|
|
119
|
+
return { type: range ? "text" : "element", quote, prefix, suffix, selector: selector(element), fullPath: selector(element),
|
|
120
|
+
element: identifyElement(element, visibleText), styles: getComputedSnapshot(element), accessibility: getA11yInfo(element),
|
|
121
|
+
rect: Object.fromEntries(["x", "y", "width", "height"].map(key => [key, Math.round(rect[key])])),
|
|
122
|
+
viewport: { width: innerWidth, height: innerHeight, scrollX, scrollY } }
|
|
123
|
+
}
|
|
124
|
+
globalThis.AnnotateInspector = { capture, text: elementText }
|
|
125
|
+
})();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": 3,
|
|
3
|
+
"name": "OpenCode Annotate",
|
|
4
|
+
"version": "0.6.0",
|
|
5
|
+
"description": "Annotate HTML-based page feedback, private drafts, and paired OpenCode delivery.",
|
|
6
|
+
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp7TG2yzekNKpQvHBtj4jqkOxtoeDIBhNIjPi37Os/ksuhzPp1pHnrJPV4WV2ToatUaD5x5/SpLP8qZKLBD+wuraEE/TeclEZ8HvEs1yhlnx/S7piTG/s0eV5umuTEx2w66Hi0w3dhTC7ZZfJXCLyqs1feBtWzQx6ClgaHNYly4iJ03pV7RfguqpIaG9LV8Oa8ELA+7Ubr0BAujXrSlvqLF5oAKGoXXcpvTL5rgMRIH4Q/85tnvrk0pRVg+1z9IGNzSfjN82iveC/JAriyWABp8YuswtvKfI2Wb+KspaisBh39Y3BRqlyo8I2Cr+01uE6G5pWiJIWMLhe0glrMr5I2wIDAQAB",
|
|
7
|
+
"permissions": ["activeTab", "scripting", "storage", "sidePanel", "nativeMessaging"],
|
|
8
|
+
"action": { "default_title": "Annotate this page", "default_icon": "icons/icon-32.png" },
|
|
9
|
+
"background": { "service_worker": "worker.mjs", "type": "module" },
|
|
10
|
+
"side_panel": { "default_path": "panel.html" },
|
|
11
|
+
"commands": { "_execute_action": { "suggested_key": { "default": "Alt+Shift+A", "mac": "Alt+Shift+A" } } },
|
|
12
|
+
"icons": { "16": "icons/icon-16.png", "48": "icons/icon-48.png", "128": "icons/icon-128.png" }
|
|
13
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
color-scheme: light dark;
|
|
3
|
+
--bg: light-dark(#faf9f5, #20201f);
|
|
4
|
+
--surface: light-dark(#fff, #292927);
|
|
5
|
+
--soft: light-dark(#f0eee8, #33322f);
|
|
6
|
+
--text: light-dark(#27251f, #f2eee5);
|
|
7
|
+
--muted: light-dark(#686257, #c2bbae);
|
|
8
|
+
--line: light-dark(#ddd8ce, #49463f);
|
|
9
|
+
--input: light-dark(#8c8475, #928a7e);
|
|
10
|
+
--accent: light-dark(#944525, #f2ad90);
|
|
11
|
+
--on-accent: light-dark(#fff, #29201b);
|
|
12
|
+
--success: light-dark(#3c6548, #a5c6ab);
|
|
13
|
+
--warning: light-dark(#865122, #e9bb7e);
|
|
14
|
+
--error: light-dark(#a12929, #ffb3ac);
|
|
15
|
+
}
|
|
16
|
+
* { box-sizing: border-box; }
|
|
17
|
+
[hidden] { display: none !important; }
|
|
18
|
+
body { height: 100dvh; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, sans-serif; }
|
|
19
|
+
p, h1, h2 { margin: 0; }
|
|
20
|
+
button, select, textarea { font: inherit; color: var(--text); }
|
|
21
|
+
button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 7px 11px; border: 1px solid var(--input); border-radius: 6px; background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 550; }
|
|
22
|
+
button:hover { border-color: var(--accent); }
|
|
23
|
+
button:disabled { color: var(--muted); opacity: .6; cursor: default; }
|
|
24
|
+
button:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
|
|
25
|
+
::selection { background: var(--accent); color: var(--on-accent); }
|
|
26
|
+
textarea { caret-color: var(--accent); }
|
|
27
|
+
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
|
|
28
|
+
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
|
|
29
|
+
.panel-header { padding: 12px 16px 13px; border-bottom: 1px solid var(--line); }
|
|
30
|
+
.identity-row { display: flex; align-items: center; gap: 8px; }
|
|
31
|
+
.identity-row h1 { flex: 1; font-size: 16px; font-weight: 650; letter-spacing: -.015em; }
|
|
32
|
+
.identity-row > .icon { width: 19px; height: 19px; color: var(--accent); }
|
|
33
|
+
.icon-button { width: 32px; height: 32px; min-height: 32px; padding: 0; flex: none; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); }
|
|
34
|
+
.icon-button:hover { background: var(--soft); color: var(--text); border-color: transparent; }
|
|
35
|
+
.page-context { display: flex; align-items: baseline; gap: 8px; min-width: 0; margin-top: 9px; font-size: 13px; }
|
|
36
|
+
#page-title { min-width: 0; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
|
|
37
|
+
#page-url { min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
38
|
+
main { min-height: 0; min-width: 0; overflow: auto; padding: 14px 16px 20px; scrollbar-width: thin; scrollbar-color: var(--input) transparent; scroll-padding: 16px; }
|
|
39
|
+
.picker-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
|
|
40
|
+
#pick { flex: none; }
|
|
41
|
+
#pick-hint { font-size: 13px; color: var(--muted); }
|
|
42
|
+
#pick[aria-pressed="true"] { width: 100%; background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
|
|
43
|
+
.composer { margin-top: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
|
|
44
|
+
.section-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
|
|
45
|
+
.section-heading h2 { font-size: 14px; font-weight: 650; }
|
|
46
|
+
.section-heading > span { font-size: 13px; color: var(--muted); }
|
|
47
|
+
.selected-quote { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 12px; padding: 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--soft); }
|
|
48
|
+
.selected-quote .icon { width: 16px; height: 16px; margin-top: 2px; color: var(--muted); }
|
|
49
|
+
#quote { max-height: 80px; overflow: auto; overflow-wrap: anywhere; white-space: pre-wrap; font-size: 13px; }
|
|
50
|
+
.kind-row { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin-bottom: 11px; }
|
|
51
|
+
.kind-row button { min-height: 32px; padding: 4px 9px; gap: 5px; background: transparent; border-color: transparent; border-radius: 5px; color: var(--muted); font-weight: 400; }
|
|
52
|
+
.kind-row button[aria-checked="true"] { background: var(--surface); border-color: var(--input); color: var(--text); }
|
|
53
|
+
.kind-row .icon { width: 15px; height: 15px; }
|
|
54
|
+
label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
|
|
55
|
+
textarea, select { width: 100%; display: block; border: 1px solid var(--input); border-radius: 6px; background: var(--surface); padding: 10px; }
|
|
56
|
+
textarea { min-height: 96px; resize: vertical; line-height: 1.5; font-size: 14px; }
|
|
57
|
+
textarea::placeholder { color: var(--muted); opacity: 1; }
|
|
58
|
+
.composer-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
|
|
59
|
+
kbd { font: 12px/1.3 system-ui; color: var(--muted); }
|
|
60
|
+
.text-button { min-height: 32px; padding: 4px 3px; border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 400; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: transparent; }
|
|
61
|
+
.text-button:hover { color: var(--text); text-decoration-color: currentColor; }
|
|
62
|
+
.soft { background: transparent; border-color: var(--line); }
|
|
63
|
+
.switch-notice, .draft-error { margin: 12px 0; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; }
|
|
64
|
+
.switch-notice strong { display: block; margin-bottom: 4px; color: var(--warning); }
|
|
65
|
+
.switch-notice p, .draft-error p { margin-bottom: 8px; color: var(--muted); }
|
|
66
|
+
.switch-actions { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
67
|
+
.notes-section { margin-top: 22px; }
|
|
68
|
+
ol { list-style: none; margin: 0; padding: 0; }
|
|
69
|
+
.note { display: grid; grid-template-columns: 24px minmax(0, 1fr); column-gap: 10px; border-top: 1px solid var(--line); padding: 15px 0 14px; }
|
|
70
|
+
.note:first-child { border-top: 0; padding-top: 5px; }
|
|
71
|
+
.note-number { display: grid; place-items: center; width: 24px; height: 24px; margin-top: 2px; border: 1px solid var(--input); border-radius: 50%; color: var(--muted); font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
|
|
72
|
+
.note.is-current .note-number { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
|
|
73
|
+
.note-target { display: flex; align-items: flex-start; gap: 6px; width: 100%; min-height: 28px; padding: 2px 0; border: 0; background: transparent; color: var(--muted); font-size: 13px; line-height: 1.5; font-weight: 400; text-align: left; }
|
|
74
|
+
.note-target span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
|
|
75
|
+
.note-target .icon { width: 14px; height: 14px; margin-top: 3px; }
|
|
76
|
+
.note-target:hover { color: var(--accent); }
|
|
77
|
+
.note-comment { margin: 4px 0 7px; overflow-wrap: anywhere; white-space: pre-wrap; }
|
|
78
|
+
.note-bottom { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
|
79
|
+
.note-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1 1 90px; font-size: 13px; color: var(--muted); }
|
|
80
|
+
.sent-mark { color: var(--success); display: inline-flex; align-items: center; gap: 3px; }
|
|
81
|
+
.sent-mark .icon { width: 14px; height: 14px; }
|
|
82
|
+
.note-bottom .text-button { padding-right: 6px; }
|
|
83
|
+
.warning { margin: 7px 0; font-size: 13px; color: var(--warning); }
|
|
84
|
+
.error, .draft-error .error { color: var(--error); overflow-wrap: anywhere; }
|
|
85
|
+
#page-error { margin-bottom: 12px; font-size: 13px; }
|
|
86
|
+
.empty-state { margin-top: 28px; }
|
|
87
|
+
.empty-state h2 { font-size: 17px; font-weight: 600; letter-spacing: -.015em; margin-bottom: 9px; }
|
|
88
|
+
.empty-state p { color: var(--muted); max-width: 28ch; }
|
|
89
|
+
.empty-state .empty-footnote { margin-top: 24px; font-size: 13px; }
|
|
90
|
+
.inline-notice { display: flex; align-items: center; gap: 8px; padding: 10px 0; margin-top: 12px; font-size: 13px; color: var(--muted); }
|
|
91
|
+
.inline-notice span { flex: 1; }
|
|
92
|
+
.delivery { min-width: 0; padding: 10px 16px 12px; border-top: 1px solid var(--line); background: var(--bg); }
|
|
93
|
+
.destination { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; min-width: 0; }
|
|
94
|
+
.destination > .icon { width: 16px; height: 16px; color: var(--muted); }
|
|
95
|
+
.destination-label { color: var(--muted); font-size: 13px; }
|
|
96
|
+
.destination-button { display: inline-flex; align-items: center; justify-content: flex-start; gap: 5px; min-width: 0; flex: 1; min-height: 28px; padding: 3px 0; border: 0; background: transparent; font-size: 13px; font-weight: 400; text-align: left; }
|
|
97
|
+
#paired { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
98
|
+
.destination-button .icon { width: 14px; height: 14px; color: var(--muted); }
|
|
99
|
+
#send { width: 100%; min-height: 39px; font-size: 14px; font-weight: 600; }
|
|
100
|
+
.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
|
|
101
|
+
.primary:disabled { opacity: 1; background: var(--soft); border-color: var(--line); color: var(--muted); }
|
|
102
|
+
#status { margin-top: 7px; min-height: 19px; font-size: 13px; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
|
|
103
|
+
#status.error { color: var(--error); }
|
|
104
|
+
#status.success { color: var(--success); }
|
|
105
|
+
.session-chooser, .utilities { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
|
|
106
|
+
.session-chooser select { padding: 8px; font-size: 13px; }
|
|
107
|
+
.hint { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
|
|
108
|
+
#connection-hint { margin-top: 7px; }
|
|
109
|
+
#refresh-targets { margin-top: 8px; }
|
|
110
|
+
.utility-row { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
111
|
+
details { margin-top: 10px; }
|
|
112
|
+
summary { min-height: 30px; padding: 4px 0; cursor: pointer; color: var(--muted); font-size: 13px; }
|
|
113
|
+
pre { max-height: 240px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font: 12px/1.5 ui-monospace, monospace; }
|
|
114
|
+
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>OpenCode Annotate</title><link rel="stylesheet" href="panel.css"></head>
|
|
4
|
+
<body>
|
|
5
|
+
<svg class="icon-definitions" aria-hidden="true"><defs>
|
|
6
|
+
<symbol id="icon-annotate" viewBox="0 0 24 24"><path d="M4 4h16v12H9l-5 4V4Z"/><path d="m9 12 6-6 3 3-6 6H9v-3Z"/></symbol>
|
|
7
|
+
<symbol id="icon-pick" viewBox="0 0 24 24"><path d="M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5M9 9l3 10 2-5 5-2-10-3Z"/></symbol>
|
|
8
|
+
<symbol id="icon-more" viewBox="0 0 24 24"><circle cx="5" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/></symbol>
|
|
9
|
+
<symbol id="icon-chevron" viewBox="0 0 24 24"><path d="m7 10 5 5 5-5"/></symbol>
|
|
10
|
+
<symbol id="icon-comment" viewBox="0 0 24 24"><path d="M4 4h16v12H9l-5 4V4Z"/></symbol>
|
|
11
|
+
<symbol id="icon-question" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M9.5 8a2.7 2.7 0 0 1 5 .7c0 2-2.5 2.2-2.5 4.3m0 3v.1"/></symbol>
|
|
12
|
+
<symbol id="icon-arrow" viewBox="0 0 24 24"><path d="M5 12h14m-6-6 6 6-6 6"/></symbol>
|
|
13
|
+
<symbol id="icon-reveal" viewBox="0 0 24 24"><path d="M13 5h6v6m0-6L9 15M9 5H5v14h14v-4"/></symbol>
|
|
14
|
+
<symbol id="icon-check" viewBox="0 0 24 24"><path d="m5 12 4 4L19 6"/></symbol>
|
|
15
|
+
<symbol id="icon-trash" viewBox="0 0 24 24"><path d="M4 6h16M9 6V3h6v3M6 6l1 15h10l1-15M10 10v7m4-7v7"/></symbol>
|
|
16
|
+
<symbol id="icon-session" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="m7 9 3 3-3 3m6 0h4"/></symbol>
|
|
17
|
+
<symbol id="icon-copy" viewBox="0 0 24 24"><rect x="8" y="8" width="12" height="13" rx="2"/><path d="M16 8V3H3v13h5"/></symbol>
|
|
18
|
+
<symbol id="icon-download" viewBox="0 0 24 24"><path d="M12 3v12m-5-5 5 5 5-5M4 16v5h16v-5"/></symbol>
|
|
19
|
+
</defs></svg>
|
|
20
|
+
<header class="panel-header">
|
|
21
|
+
<div class="identity-row"><svg class="icon" aria-hidden="true"><use href="#icon-annotate"/></svg><h1>Annotate</h1><button id="more" class="icon-button" aria-label="More review options" title="More review options" aria-expanded="false" aria-controls="utilities"><svg class="icon" aria-hidden="true"><use href="#icon-more"/></svg></button></div>
|
|
22
|
+
<div class="page-context"><strong id="page-title">Open a page</strong><span id="page-url"></span></div>
|
|
23
|
+
</header>
|
|
24
|
+
<main id="panel-body">
|
|
25
|
+
<section id="utilities" class="utilities" aria-label="Review utilities" hidden>
|
|
26
|
+
<div class="utility-row"><button id="copy"><svg class="icon" aria-hidden="true"><use href="#icon-copy"/></svg>Copy Markdown</button><button id="export"><svg class="icon" aria-hidden="true"><use href="#icon-download"/></svg>Export JSON</button></div>
|
|
27
|
+
<details id="context-details"><summary>Review context · all saved notes</summary><pre id="preview"></pre></details>
|
|
28
|
+
</section>
|
|
29
|
+
<section id="session-options" class="session-chooser" aria-label="Destination selection" hidden>
|
|
30
|
+
<label for="targets">Choose session</label><select id="targets"><option value="">Choose a session…</option></select>
|
|
31
|
+
<p id="connection-hint" class="hint" aria-live="polite"></p><button id="refresh-targets">Refresh sessions</button>
|
|
32
|
+
</section>
|
|
33
|
+
<p id="page-error" class="error" role="alert" hidden></p>
|
|
34
|
+
<div class="picker-row"><button id="pick" aria-pressed="false"><svg class="icon" aria-hidden="true"><use href="#icon-pick"/></svg><span id="pick-label">Pick element</span></button><span id="pick-hint">or select text</span></div>
|
|
35
|
+
<section id="composer" class="composer" aria-label="Current annotation" hidden>
|
|
36
|
+
<div class="section-heading"><h2 id="composer-title">New note</h2><span id="draft-state" aria-live="polite"></span></div>
|
|
37
|
+
<blockquote class="selected-quote"><svg class="icon" aria-hidden="true"><use href="#icon-pick"/></svg><p id="quote"></p></blockquote>
|
|
38
|
+
<p id="anchor-warning" class="warning" hidden></p>
|
|
39
|
+
<div id="switch-notice" class="switch-notice" aria-live="polite" hidden><strong>Keep feedback with this selection</strong><p id="switch-description"></p><div class="switch-actions"><button id="save-switch">Add & switch</button><button id="keep-editing" class="soft">Keep editing</button><button id="discard-switch" class="text-button">Discard & switch</button></div></div>
|
|
40
|
+
<div id="kind" class="kind-row" role="radiogroup" aria-label="Feedback type"><button id="kind-comment" role="radio" aria-checked="true" tabindex="0" data-kind="comment"><svg class="icon" aria-hidden="true"><use href="#icon-comment"/></svg>Comment</button><button id="kind-ask" role="radio" aria-checked="false" tabindex="-1" data-kind="ask"><svg class="icon" aria-hidden="true"><use href="#icon-question"/></svg>Question</button></div>
|
|
41
|
+
<label for="comment">Your feedback</label><textarea id="comment" rows="4" maxlength="8000" placeholder="What should change, or what would you like to know?"></textarea>
|
|
42
|
+
<div id="draft-error" class="draft-error" hidden><p id="draft-error-text" class="error" role="alert"></p><div class="switch-actions"><button id="retry-draft">Retry saving draft</button><button id="reload-draft">Load saved draft</button><button id="keep-draft">Keep my draft</button><button id="copy-draft" class="text-button">Copy my draft</button></div></div>
|
|
43
|
+
<div class="composer-actions"><button id="save" aria-keyshortcuts="Control+Enter Meta+Enter"><span id="save-label">Add note</span><kbd id="save-shortcut" title="Command or Control + Enter" aria-hidden="true">⌘↵</kbd></button><button id="cancel" class="text-button">Discard draft</button></div>
|
|
44
|
+
</section>
|
|
45
|
+
<div id="undo-notice" class="inline-notice" aria-live="polite" hidden><span>Note removed.</span><button id="undo" class="text-button">Undo</button></div>
|
|
46
|
+
<section id="notes-section" class="notes-section" aria-label="Collected notes" hidden><div class="section-heading"><h2>Notes</h2><span id="count">0 notes</span></div><ol id="notes"></ol></section>
|
|
47
|
+
<section id="empty-state" class="empty-state"><h2>Start with what you see.</h2><p>Pick an element or highlight text on the page, then describe what needs attention.</p><p class="empty-footnote">Send one note straight away, or collect a few first. Your feedback stays local until you send.</p></section>
|
|
48
|
+
</main>
|
|
49
|
+
<footer class="delivery">
|
|
50
|
+
<div class="destination"><svg class="icon" aria-hidden="true"><use href="#icon-session"/></svg><span class="destination-label">To</span><button id="change-target" class="destination-button" aria-label="Change destination session" aria-expanded="false" aria-controls="session-options"><span id="paired">Looking for your session…</span><svg class="icon" aria-hidden="true"><use href="#icon-chevron"/></svg></button></div>
|
|
51
|
+
<button id="send" class="primary" aria-describedby="paired status"><svg id="send-check" class="icon" aria-hidden="true" hidden><use href="#icon-check"/></svg><span id="send-label">Send & continue</span><svg id="send-arrow" class="icon" aria-hidden="true" hidden><use href="#icon-arrow"/></svg></button>
|
|
52
|
+
<p id="status" role="status" aria-live="polite">Looking for your OpenCode session…</p>
|
|
53
|
+
</footer>
|
|
54
|
+
<script type="module" src="panel.mjs"></script>
|
|
55
|
+
</body>
|
|
56
|
+
</html>
|