annotepage-client 2.34.0 → 2.36.0-rc.1
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/README.md +1 -0
- package/dist/HASHES.txt +6 -1
- package/dist/annotepage-frame.js +2371 -0
- package/dist/annotepage.js +1003 -491
- package/package.json +1 -1
package/dist/annotepage.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* ============================================================================
|
|
2
2
|
annotepage -- the annotation layer, browser side.
|
|
3
3
|
|
|
4
|
-
Package version : 2.
|
|
4
|
+
Package version : 2.36.0-rc.1
|
|
5
5
|
Format version : 2 (see FORMAT.md)
|
|
6
6
|
Licence : MIT
|
|
7
7
|
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
/* Injected by the build: they come from package.json and from
|
|
17
17
|
src/styles.css, so that no value is written in two places and can
|
|
18
18
|
therefore diverge. */
|
|
19
|
-
const TOOL_VERSION = "2.
|
|
19
|
+
const TOOL_VERSION = "2.36.0-rc.1";
|
|
20
20
|
const FORMAT = 2;
|
|
21
|
-
const STYLES = "/* ============================================================================\n styles.css -- THE STYLES OF THE TOOL, AND OF NO OTHER ELEMENT.\n\n This sheet is INLINED into the served file by the build, then put into the\n tool's shadow root -- as a constructed sheet when the browser can do it, in\n a <style> otherwise. It was loaded by a <link> in the original tool; the\n move to a CDN under SRI brought it inside the file, so that there is only\n one digest to keep up to date. The containment itself has not changed, and\n is still twofold:\n\n - from the tool towards the site: no rule from here can reach an element\n of the host site, the browser sees to that. That is what makes the\n claim \"the layer touches nothing\" checkable rather than promised;\n - from the site towards the tool: no rule of the site can reach an\n element here. A redesign of the site's stylesheet therefore cannot\n distort the tool, nor the other way round.\n\n The \"ap-\" prefix on every class is the third safeguard: the day somebody\n loads these styles WITHOUT a shadow root -- by mistake, or to debug --\n nothing would answer a selector of the site.\n\n NO RULE TARGETS html, body, * OR ANY SELECTOR OF THE SITE. That is the one\n absolute prohibition of this file.\n\n COLOURS: the tool has its OWN palette, defined on the shadow root. It\n reads neither the site's variables nor its theme attribute: it has no\n reason to know how the site names its colours, and it must stay readable\n on a light site as on a dark one. The switch follows the system\n preference, the only information the tool has without asking anyone.\n ============================================================================ */\n\n\n:host {\n --ap-bg: #ffffff;\n --ap-bg-soft: #f4f6f8;\n --ap-bg-raised: #e9edf2;\n --ap-text: #1a1d21;\n --ap-text-soft: #5b6570;\n --ap-border: #d5dbe2;\n --ap-accent: #2f6fed;\n --ap-accent-dark: #1d55c8;\n --ap-accent-text: #ffffff;\n --ap-accent-veil: rgba(47, 111, 237, 0.14);\n --ap-alert-bg: #fdeceb;\n --ap-alert-border: #e3a9a4;\n --ap-alert-text: #8a1f16;\n /* THE TWO STATES A REMARK CAN BE IN ONCE IT IS ANSWERED, as tokens rather\n than as literals. They were literals, written once inside the card's\n state mark -- which meant the dark theme drew them at the LIGHT theme's\n ink: measured, 2.42:1 for \"resolved\" and 2.02:1 against the veil they\n sit on, where WCAG 1.4.3 asks 4.5. Below they are 4.68 and 5.23 in the\n light theme, 6.43 and 6.64 in the dark one, on the same composite.\n\n `pending` is the state that must never be mistaken for done: resolved,\n but not deployed -- the defect is still on the reader's screen. `fill`\n is the same colour asked to carry --ap-accent-text on top of it, for the\n badge on the page: 5.93:1 in light, 10.14:1 in dark. */\n --ap-done-ink: #0f7a52;\n --ap-done-veil: rgba(16, 185, 129, 0.14);\n --ap-pending-ink: #8a5a00;\n --ap-pending-veil: rgba(245, 158, 11, 0.16);\n --ap-pending-fill: #8a5a00;\n --ap-shadow: 0 6px 24px rgba(16, 24, 40, 0.18);\n --ap-radius: 10px;\n --ap-font: system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\",\n Arial, sans-serif;\n}\n\n@media (prefers-color-scheme: dark) {\n :host {\n --ap-bg: #1d2126;\n --ap-bg-soft: #262b32;\n --ap-bg-raised: #323942;\n --ap-text: #e9ecf0;\n --ap-text-soft: #a4adb8;\n --ap-border: #3a424c;\n --ap-accent: #6d9bff;\n --ap-accent-dark: #8fb4ff;\n --ap-accent-text: #10151c;\n --ap-accent-veil: rgba(109, 155, 255, 0.18);\n --ap-alert-bg: #3a1f1c;\n --ap-alert-border: #7c3a33;\n --ap-alert-text: #ffb9b1;\n --ap-done-ink: #56d3a0;\n --ap-done-veil: rgba(16, 185, 129, 0.18);\n --ap-pending-ink: #f0b757;\n --ap-pending-veil: rgba(245, 158, 11, 0.16);\n --ap-pending-fill: #f0b757;\n --ap-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);\n }\n}\n\n/* ----------------------------------------------------------------------------\n The layer.\n\n It covers the viewport and receives NO click: that is what lets the page\n behave exactly as usual as long as the tool is not in annotation mode.\n Each widget re-enables clicks for itself alone.\n ---------------------------------------------------------------------------- */\n\n.ap-layer {\n position: absolute;\n inset: 0;\n pointer-events: none;\n font-family: var(--ap-font);\n font-size: 14px;\n line-height: 1.45;\n color: var(--ap-text);\n text-align: left;\n -webkit-font-smoothing: antialiased;\n}\n\n.ap-layer button,\n.ap-layer input,\n.ap-layer textarea {\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n color: inherit;\n margin: 0;\n box-sizing: border-box;\n}\n\n/* ----------------------------------------------------------------------------\n The button: the only thing visible when the tool is at rest.\n ---------------------------------------------------------------------------- */\n\n.ap-button {\n position: fixed;\n right: 16px;\n bottom: 16px;\n display: inline-flex;\n align-items: center;\n gap: 8px;\n padding: 9px 14px;\n border: 1px solid var(--ap-border);\n border-radius: 999px;\n background: var(--ap-bg);\n color: var(--ap-text);\n box-shadow: var(--ap-shadow);\n cursor: pointer;\n pointer-events: auto;\n opacity: 0.92;\n transition: opacity 0.15s ease, transform 0.15s ease;\n}\n\n.ap-button:hover,\n.ap-button:focus-visible {\n opacity: 1;\n transform: translateY(-1px);\n}\n\n.ap-button:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 2px;\n}\n\n.ap-button[aria-pressed=\"true\"] {\n background: var(--ap-accent);\n border-color: var(--ap-accent);\n color: var(--ap-accent-text);\n opacity: 1;\n}\n\n.ap-button-dot {\n display: inline-block;\n width: 8px;\n height: 8px;\n border-radius: 50%;\n background: var(--ap-accent);\n flex: none;\n}\n\n.ap-button[aria-pressed=\"true\"] .ap-button-dot {\n background: var(--ap-accent-text);\n}\n\n.ap-button-count {\n padding: 1px 7px;\n border-radius: 999px;\n background: var(--ap-bg-raised);\n color: var(--ap-text-soft);\n font-size: 12px;\n}\n\n.ap-button[aria-pressed=\"true\"] .ap-button-count {\n background: rgba(255, 255, 255, 0.22);\n color: var(--ap-accent-text);\n}\n\n/* ----------------------------------------------------------------------------\n The pointing highlight.\n\n It is DRAWN HERE, from the coordinates of the element being pointed at.\n Nothing is put on the element itself: no class, no attribute, no style. So\n the site cannot move by a single pixel because of the pointing.\n ---------------------------------------------------------------------------- */\n\n.ap-highlight {\n position: fixed;\n border: 2px solid var(--ap-accent);\n border-radius: 3px;\n background: var(--ap-accent-veil);\n pointer-events: none;\n display: none;\n}\n\n.ap-highlight-label {\n position: fixed;\n max-width: 320px;\n padding: 4px 8px;\n border-radius: 6px;\n background: var(--ap-accent);\n color: var(--ap-accent-text);\n font-size: 12px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n pointer-events: none;\n display: none;\n box-shadow: var(--ap-shadow);\n}\n\n/* ----------------------------------------------------------------------------\n The zones a remark can be written in (data-zone), while annotation mode is on.\n\n DISCREET ON PURPOSE: a dashed line and no fill. The page under review is\n what the reviewer is reading, and a veil over every open area would tint\n the very colours they may be writing about. Drawn from coordinates, like\n the highlight: nothing is put on the site's element.\n ---------------------------------------------------------------------------- */\n\n.ap-zone {\n position: fixed;\n border: 1px dashed var(--ap-accent);\n border-radius: 4px;\n opacity: 0.6;\n pointer-events: none;\n box-sizing: border-box;\n}\n\n.ap-zone-notice {\n position: fixed;\n max-width: 280px;\n padding: 6px 10px;\n border: 1px solid var(--ap-border);\n border-radius: 6px;\n background: var(--ap-bg);\n color: var(--ap-text);\n font-size: 13px;\n box-shadow: var(--ap-shadow);\n pointer-events: none;\n display: none;\n}\n\n/* ----------------------------------------------------------------------------\n The markers: \"there are already notes here\".\n ---------------------------------------------------------------------------- */\n\n.ap-marker {\n position: fixed;\n min-width: 22px;\n height: 22px;\n padding: 0 6px;\n border: 2px solid var(--ap-bg);\n border-radius: 999px;\n background: var(--ap-accent);\n color: var(--ap-accent-text);\n font-size: 12px;\n font-weight: 700;\n line-height: 18px;\n text-align: center;\n cursor: pointer;\n pointer-events: auto;\n box-shadow: var(--ap-shadow);\n}\n\n/* THE STATE, IN THE BADGE ITSELF. The rule above is the OPEN state -- work to\n do -- and it stays the tool's accent, because that is what a badge on a page\n has always meant here. The other two are read against it:\n\n pending filled amber. Resolved, not deployed: the defect is still on the\n screen the reader is looking at, and it is the one state worth\n catching an eye that was not looking for it.\n done hollow, in the soft ink. History: there, countable, and not\n asking for anything.\n\n THE COLOUR IS NEVER ALONE. The count is written in the badge and the state\n is spelled out in its accessible name -- a badge that said \"still to fix\"\n by hue only would say nothing at all to a good part of its readers. */\n.ap-marker-pending {\n background: var(--ap-pending-fill);\n}\n.ap-marker-done {\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-weight: 600;\n /* The 2px border is the halo against the page and cannot be spent on the\n outline, so the outline is drawn inside. */\n box-shadow: var(--ap-shadow), inset 0 0 0 1px var(--ap-border);\n}\n\n.ap-marker:focus-visible {\n outline: 2px solid var(--ap-accent-dark);\n outline-offset: 2px;\n}\n\n/* ----------------------------------------------------------------------------\n The panel.\n ---------------------------------------------------------------------------- */\n\n.ap-panel {\n position: fixed;\n top: 12px;\n right: 12px;\n bottom: 72px;\n width: 360px;\n max-width: calc(100vw - 24px);\n display: none;\n flex-direction: column;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg);\n box-shadow: var(--ap-shadow);\n pointer-events: auto;\n overflow: hidden;\n}\n\n.ap-panel.ap-open {\n display: flex;\n}\n\n/* The other side. Two positions, right and left, and no third one: in\n annotation mode the layer takes every click, so every pixel of panel is a\n pixel of page that can no longer be pointed at. A floating panel would\n only move that loss around.\n\n \"bottom\" IS NOT REDECLARED, on purpose: the panel keeps the same 72 px of\n clearance above the floating button either way, and that clearance is the\n same on both sides because the button moves WITH it.\n\n AND THE BUTTON MOVES WITH IT, which was decided the other way first. The\n argument for leaving it was that it is the tool's only visible trace at\n rest, so an anchor that moved would stop being one. The owner's answer,\n and it is the better one: \"move left\" is asked of the TOOL, not of half of\n it. A panel on one edge and the control that opens it on the other makes\n the eye cross the whole window for one gesture, and somebody who set the\n side set it for the tool.\n\n TWO THINGS THIS RULE DEPENDS ON, both fragile:\n - it is written with ONE class, so it weighs exactly what \".ap-panel\"\n weighs;\n - it is written BEFORE the narrow block below.\n Reverse either and it wins under 560 px, where the panel is a bottom band\n spanning the width -- and a panel pinned to the left there is the full-\n height panel whose defect at 375 px is described in that block. */\n.ap-left {\n right: auto;\n left: 12px;\n}\n/* The button follows, and it is put on the LAYER and not on the panel: the\n button is not inside the panel, so the side has to be readable from a\n common ancestor. Same offset mirrored, same bottom -- only the edge\n changes. */\n.ap-layer.ap-left-side .ap-button {\n right: auto;\n left: 16px;\n}\n\n/* ----------------------------------------------------------------------------\n DOCKED (the `container` option): the panel FILLS the element the host page\n handed over, and there is no floating button -- the page opens and closes the\n tool. One class, added only when `container` is set (buildUi), so none of the\n floating layout above is touched without it.\n\n Two classes of specificity, so it wins over the edge-card rules and over the\n narrow-screen bottom band below: inside a container, the container's own box\n is what decides the size, not the viewport. The markers, the highlight and\n the pointing stay viewport-fixed and are untouched here -- only the panel\n moves from a floating card to a fill.\n ---------------------------------------------------------------------------- */\n.ap-docked .ap-button { display: none; }\n.ap-docked .ap-side-toggle { display: none; }\n.ap-docked .ap-panel {\n position: absolute;\n inset: 0;\n width: auto;\n max-width: none;\n border: 0;\n border-radius: 0;\n box-shadow: none;\n}\n\n.ap-panel-header {\n display: flex;\n align-items: baseline;\n gap: 8px;\n padding: 12px 14px;\n border-bottom: 1px solid var(--ap-border);\n background: var(--ap-bg-soft);\n}\n\n.ap-panel-title {\n font-size: 15px;\n font-weight: 600;\n flex: 1 1 auto;\n}\n\n/* -- what the whole project holds ---------------------------------------\n THE FIRST LINE OF THE FOOTER, on its own row. The footer is a flex row of\n short things -- a name, two buttons -- so this takes the whole width and the\n rest wraps under it. No ground and no border of its own: it is IN the footer,\n not beside it. */\n/* The retention line, when there is one. `:empty` rather than a class the\n script has to add and remove: the element is always there, and CSS decides\n whether it takes any room -- so a server that deletes nothing costs the\n panel exactly nothing. */\n.ap-panel-keeps { margin-top: 6px; color: var(--ap-text-soft); }\n.ap-panel-keeps:empty { display: none; }\n\n.ap-panel-footer { flex-wrap: wrap; }\n\n/* WHO YOU ARE SIGNING AS, ON A LINE OF ITS OWN. `flex-basis: 100%` is the same\n device the block above uses, and for the same reason: the footer is one\n wrapping row and everything in it was being strung end to end. */\n.ap-foot-who {\n flex-basis: 100%;\n display: flex; align-items: baseline; gap: 8px;\n}\n\n/* -- the list of remarks -------------------------------------------------\n A ROW, AND EVERY ROW IS A BUTTON. Not a card with a link in it: the whole\n line is the target, which is what a list of things to open should be, and it\n is reachable with a keyboard for free.\n\n THE EXCERPT TAKES THE ROOM AND FOLDS TO ONE LINE. What a remark is about can\n be a paragraph; what a list can show is a line. The author keeps a fixed\n place at the end so the eye can run down it. */\n.ap-row {\n display: flex; align-items: baseline; gap: 8px;\n width: 100%; margin: 0 0 4px; padding: 8px 10px;\n border: 1px solid var(--ap-border); border-radius: 8px;\n background: var(--ap-bg); color: var(--ap-text);\n font: inherit; text-align: left; cursor: pointer;\n transition: border-color .15s ease, background-color .15s ease;\n}\n.ap-row:hover { background: var(--ap-bg-soft); border-color: var(--ap-accent); }\n.ap-row:focus-visible { outline: 2px solid var(--ap-accent); outline-offset: 2px; }\n.ap-row-about {\n flex: 1; min-width: 0;\n overflow: hidden; text-overflow: ellipsis; white-space: nowrap;\n}\n.ap-row-who { flex: none; font-size: 12px; color: var(--ap-text-soft); }\n/* THE STATE, AS A DOT. Three of them, and the middle one is the one that must\n not read as done: resolved but not deployed is a defect still on screen. The\n accessible name spells all three out -- a colour is not a fact for\n everybody. */\n.ap-row-dot {\n flex: none; width: 8px; height: 8px; border-radius: 999px;\n background: var(--ap-accent); align-self: center;\n}\n.ap-row-pending .ap-row-dot { background: var(--ap-text-soft); }\n.ap-row-done .ap-row-dot { background: transparent; border: 1px solid var(--ap-border); }\n.ap-row-done .ap-row-about { color: var(--ap-text-soft); }\n@media (prefers-reduced-motion: reduce) { .ap-row { transition: none; } }\n\n/* -- a window that is not the panel --------------------------------------\n IT FLOATS OVER THE PAGE, and that is the point: the panel is a band down one\n edge, and what goes in here is not about the page beside it. Fixed rather\n than absolute -- the reader scrolls the page under it, and a window that\n scrolled away with the article would have to be chased.\n\n ABOVE THE PANEL AND BELOW NOTHING. It is opened from the panel's footer, so\n it must cover it; the tool's own layer already sits above the site.\n\n WIDTH: it is read, not filled in. 26rem is a paragraph, and min() keeps it\n inside a phone without a media query. */\n.ap-pop {\n position: fixed; z-index: 3;\n /* THE LAYER IS `pointer-events: none` so the site underneath keeps working,\n and every piece that must be reachable turns it back on. Without this\n line the window is a picture: no click on its buttons, and no drag on its\n bar -- which is exactly how it behaved when first measured. */\n pointer-events: auto;\n width: min(26rem, calc(100vw - 24px));\n max-height: calc(100vh - 24px);\n display: flex; flex-direction: column;\n border: 1px solid var(--ap-border); border-radius: 12px;\n background: var(--ap-bg); color: var(--ap-text);\n box-shadow: 0 18px 48px rgba(0, 0, 0, .22);\n overflow: hidden;\n}\n/* THE HANDLE. `touch-action: none` is what makes a finger drag the window\n instead of scrolling the page under it -- without it the browser claims the\n gesture before the first pointermove arrives. */\n.ap-pop-bar {\n display: flex; align-items: center; gap: 8px;\n padding: 8px 12px;\n border-bottom: 1px solid var(--ap-border);\n background: var(--ap-bg-soft);\n cursor: grab; touch-action: none; user-select: none;\n}\n.ap-pop-moving .ap-pop-bar { cursor: grabbing; }\n.ap-pop-title { flex: 1; font-size: 13px; font-weight: 650; }\n/* `min-height: 0` is what makes the scroll happen INSIDE the window rather\n than the window growing past its own height: a flex item does not shrink\n below its content without it, and the end of a long remark would be behind\n the bottom edge with nothing to scroll. */\n.ap-pop-body { flex: 1 1 auto; min-height: 0; padding: 12px; overflow: auto; }\n/* The one line that says why the page stayed where it was. Drawn as the panel\n draws its own help text, not as an alert: nothing has gone wrong. */\n.ap-why {\n margin: 0 0 10px; padding: 8px 10px;\n border-radius: 8px; background: var(--ap-bg-soft);\n color: var(--ap-text-soft); font-size: 12.5px;\n}\n/* THE CORNER, AND IT IS DRAWN RATHER THAN LEFT TO THE BROWSER. `resize: both`\n would have done this in one line and does nothing under a finger on iOS; the\n window is moved with pointer events for exactly that reason, and it is\n resized with them too. Two hairlines, the shape everybody already reads as a\n grip, in the same ink as the borders around it. */\n.ap-pop-grip {\n position: absolute; right: 0; bottom: 0;\n width: 18px; height: 18px;\n cursor: nwse-resize; touch-action: none;\n background:\n linear-gradient(135deg, transparent 42%, var(--ap-border) 42%,\n var(--ap-border) 54%, transparent 54%),\n linear-gradient(135deg, transparent 66%, var(--ap-border) 66%,\n var(--ap-border) 78%, transparent 78%);\n}\n.ap-pop-sizing { user-select: none; }\n.ap-pop-sizing .ap-pop-grip { cursor: nwse-resize; }\n/* Inside a window, the block is the window: no second frame around it. */\n.ap-pop-body .ap-config { margin: 0; padding: 0; border: 0; background: none; }\n.ap-pop-body .ap-forget { margin: 0; }\n.ap-pop-body .ap-panel-stats { margin: 0; }\n.ap-pop-body .ap-stats { margin: 0; }\n/* A WINDOW HAS ROOM, SO THE FILE GETS IT. In the panel this field was two or\n four lines because the column had nothing to spare; here it can show the\n whole thing without being scrolled. */\n.ap-pop-body .ap-code { min-height: 9.5em; }\n\n/* -- the file the assistant needs ---------------------------------------\n Drawn like the other block the panel opens in its body -- a title, a\n sentence, the thing itself, two buttons -- so nothing here is a new shape to\n learn. The last line is the warning, and it is a line and not a dialog: the\n reviewer asked for this file. */\n.ap-config {\n margin: 10px 0 0; padding: 12px;\n border: 1px solid var(--ap-border); border-radius: 10px;\n background: var(--ap-bg-soft);\n}\n/* The warning is a line at the tool's own soft ink, not in an alert colour:\n the reviewer asked for this file, they are not being warned off it. There is\n no --ap-warn token and this does not invent one. */\n.ap-config .ap-warn { margin-top: 10px; }\n.ap-panel-stats {\n flex-basis: 100%;\n display: flex; flex-wrap: wrap; gap: 4px 18px;\n margin-bottom: 4px;\n}\n.ap-stat { display: inline-flex; align-items: baseline; gap: 5px; }\n/* The row says what it counts, once, and the three figures follow it. Without\n it, \"3 / 2 / 1\" beside a panel about one page reads as being about that\n page. */\n.ap-stat-label {\n flex-basis: 100%; margin-bottom: 2px;\n font-size: 11px; font-weight: 650; letter-spacing: .02em;\n text-transform: uppercase; color: var(--ap-text-soft);\n}\n.ap-stat-n { font-size: 15px; font-weight: 650; color: var(--ap-text); }\n.ap-stat-w { font-size: 12px; color: var(--ap-text-soft); }\n/* UP TO THREE BLOCKS: this site, the server, every server. Each is a label and\n the figures it holds, and the figures are the same size in all three. */\n.ap-stats { display: flex; flex-direction: column; gap: 14px; }\n.ap-stats-block { display: flex; flex-direction: column; gap: 4px; }\n.ap-stats .ap-panel-stats { margin-bottom: 0; }\n/* What follows a label on its line -- \"updated daily\" -- is about the label,\n not part of it: lower case, lighter, after a dot. */\n.ap-stat-aside { font-weight: 400; letter-spacing: 0; text-transform: none; }\n.ap-stat-aside::before { content: \"\\00b7\"; margin: 0 6px; }\n/* THE LAST BLOCK IS NOT THIS SERVER'S. A soft ground sets it apart from the\n two above it, which are; nothing about it is larger. */\n.ap-stats-world {\n margin: 0 -8px; padding: 8px;\n background: var(--ap-bg-soft); border-radius: 8px;\n}\n.ap-panel-instructions {\n padding: 10px 14px;\n border-bottom: 1px solid var(--ap-border);\n color: var(--ap-text-soft);\n font-size: 13px;\n}\n\n.ap-panel-body {\n flex: 1 1 auto;\n overflow-y: auto;\n overscroll-behavior: contain;\n padding: 4px 14px 14px;\n}\n\n.ap-panel-footer {\n padding: 8px 14px;\n border-top: 1px solid var(--ap-border);\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-size: 12px;\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.ap-section-title {\n margin: 14px 0 6px;\n color: var(--ap-text-soft);\n font-size: 12px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n}\n\n.ap-section-help {\n margin: 0 0 8px;\n color: var(--ap-text-soft);\n font-size: 12px;\n}\n\n.ap-empty {\n margin: 16px 0;\n color: var(--ap-text-soft);\n}\n\n/* ----------------------------------------------------------------------------\n THE MODE BADGE: one word, drawn in both modes, at the top of every draw.\n\n It replaced a paragraph that only the public mode ever drew. Two things\n were wrong with that: secure mode said nothing, so the panel never told a\n reviewer which of the two they were in; and a paragraph pinned to the top\n for ever is skipped after the second reading, while a single word is not.\n\n IT IS NOT A BUTTON AND MUST NOT LOOK LIKE ONE. No shadow, no pressed\n state, cursor stays default: there is nothing to press. What it does have\n is a focus ring, because it takes focus -- the description below has to be\n reachable without a pointer, and that is the only reason it is focusable.\n ---------------------------------------------------------------------------- */\n\n.ap-mode {\n /* The frame the description is positioned against. It spans the width of\n the panel body, so a description pinned to its two edges cannot spill\n sideways out of a body that scrolls -- and a scrolling body clips both\n axes, not just the one it scrolls. */\n position: relative;\n margin: 4px 0 10px;\n}\n\n.ap-mode-chip {\n display: inline-block;\n padding: 2px 9px 3px;\n border: 1px solid var(--ap-border);\n border-radius: 999px;\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-size: 11px;\n font-weight: 600;\n letter-spacing: 0.05em;\n text-transform: uppercase;\n cursor: default;\n}\n\n/* The public badge is the one that carries a consequence, so it is the one\n that is coloured -- in the tool's own accent, not in the alert colours: a\n public key is a choice somebody made on purpose, not an incident. Secure\n keeps the quiet frame: it is the case where nothing is being said. */\n/* The same ring as every other focusable thing in the panel. It is the only\n visual proof, for somebody arriving by Tab, that this word is where their\n focus went. */\n.ap-mode-chip:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 2px;\n}\n\n/* Plain wears the same coat as public, and for the same reason: both are a\n choice somebody made on purpose, and both carry a consequence for whoever\n is about to write. Neither is an incident, so neither takes an alert\n colour. They cannot both be true at once. */\n.ap-mode-public .ap-mode-chip,\n.ap-mode-plain .ap-mode-chip {\n border-color: var(--ap-accent);\n background: var(--ap-accent-veil);\n color: var(--ap-accent-dark);\n}\n\n/* The description. Hidden by DEFAULT and shown on demand, and hidden in a way\n that leaves it readable to a screen reader: it is the badge's\n aria-describedby target, and an accessible description is computed from the\n referenced element whether or not it is painted. It is taken out of the\n layout entirely (absolute) so that showing it moves not one pixel of the\n list underneath -- a tooltip that pushes the notes down is a tooltip that\n makes people lose their place. */\n.ap-mode-tip {\n position: absolute;\n z-index: 2;\n top: calc(100% + 6px);\n left: 0;\n right: 0;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg-raised);\n color: var(--ap-text);\n box-shadow: var(--ap-shadow);\n font-size: 12px;\n font-weight: 400;\n letter-spacing: normal;\n text-transform: none;\n line-height: 1.45;\n opacity: 0;\n visibility: hidden;\n transform: translateY(-3px);\n transition: opacity 0.12s ease, transform 0.12s ease, visibility 0s linear 0.12s;\n pointer-events: none;\n}\n\n/* BOTH, and the keyboard one is not the afterthought: :focus-visible is what\n makes the sentence reachable by somebody who never touches a pointer. */\n.ap-mode-chip:hover ~ .ap-mode-tip,\n.ap-mode-chip:focus-visible ~ .ap-mode-tip {\n opacity: 1;\n visibility: visible;\n transform: none;\n transition: opacity 0.12s ease, transform 0.12s ease, visibility 0s;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ap-mode-tip {\n transform: none;\n transition: none;\n }\n .ap-mode-chip:hover ~ .ap-mode-tip,\n .ap-mode-chip:focus-visible ~ .ap-mode-tip {\n transition: none;\n }\n}\n\n/* The \"a newer client exists\" line and the \"this server speaks another\n format\" line are the same object on screen: a standing statement about what\n one is looking at, above the notes and above the failures. One rule, so\n they cannot drift apart -- and the second one joins it rather than\n inventing a colour, precisely because a protocol disagreement is a fact\n about the project, not an incident.\n\n Deliberately NOT the alert colours: neither is a failure, and an alarm that\n never goes away stops being read. */\n.ap-upgrade,\n.ap-format {\n margin: 0 0 10px;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-size: 12px;\n line-height: 1.45;\n}\n\n/* ----------------------------------------------------------------------------\n A note, and its replies.\n ---------------------------------------------------------------------------- */\n\n.ap-note {\n margin: 8px 0;\n padding: 10px 12px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg);\n}\n\n.ap-note.ap-orphan {\n background: var(--ap-bg-soft);\n}\n\n\n.ap-note-header {\n display: flex;\n align-items: baseline;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.ap-note-author {\n font-weight: 600;\n}\n\n.ap-note-date {\n color: var(--ap-text-soft);\n font-size: 12px;\n}\n\n.ap-note-target {\n margin: 4px 0 0;\n color: var(--ap-text-soft);\n font-size: 12px;\n font-style: italic;\n overflow-wrap: anywhere;\n}\n\n.ap-note-text {\n margin: 6px 0 0;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n\n.ap-note-actions {\n margin-top: 8px;\n display: flex;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.ap-replies {\n margin: 8px 0 0;\n padding-left: 10px;\n border-left: 2px solid var(--ap-border);\n}\n\n.ap-reply {\n margin: 8px 0 0;\n}\n\n/* ----------------------------------------------------------------------------\n The form, anchored near the element pointed at.\n ---------------------------------------------------------------------------- */\n\n.ap-form {\n position: fixed;\n width: 340px;\n max-width: calc(100vw - 24px);\n display: none;\n flex-direction: column;\n gap: 8px;\n padding: 14px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg);\n box-shadow: var(--ap-shadow);\n pointer-events: auto;\n}\n\n.ap-form.ap-open {\n display: flex;\n}\n\n.ap-form-title {\n font-size: 15px;\n font-weight: 600;\n}\n\n.ap-form-target {\n color: var(--ap-text-soft);\n font-size: 12px;\n font-style: italic;\n overflow-wrap: anywhere;\n}\n\n.ap-label {\n display: block;\n margin-bottom: 3px;\n font-size: 12px;\n font-weight: 600;\n color: var(--ap-text-soft);\n}\n\n.ap-help {\n margin: 3px 0 0;\n font-size: 12px;\n color: var(--ap-text-soft);\n}\n\n.ap-field,\n.ap-area {\n width: 100%;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: 8px;\n background: var(--ap-bg-soft);\n color: var(--ap-text);\n}\n\n.ap-field:focus,\n.ap-area:focus {\n outline: 2px solid var(--ap-accent);\n outline-offset: 1px;\n}\n\n.ap-area {\n min-height: 92px;\n resize: vertical;\n}\n\n.ap-actions {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.ap-counter {\n margin-left: auto;\n font-size: 12px;\n color: var(--ap-text-soft);\n}\n\n/* ----------------------------------------------------------------------------\n Buttons.\n ---------------------------------------------------------------------------- */\n\n.ap-primary,\n.ap-secondary,\n.ap-link {\n border-radius: 8px;\n cursor: pointer;\n pointer-events: auto;\n}\n\n.ap-primary {\n padding: 8px 14px;\n border: 1px solid var(--ap-accent);\n background: var(--ap-accent);\n color: var(--ap-accent-text);\n font-weight: 600;\n}\n\n.ap-primary:hover {\n background: var(--ap-accent-dark);\n border-color: var(--ap-accent-dark);\n}\n\n.ap-secondary {\n padding: 8px 14px;\n border: 1px solid var(--ap-border);\n background: var(--ap-bg);\n color: var(--ap-text);\n}\n\n.ap-secondary:hover {\n background: var(--ap-bg-raised);\n}\n\n.ap-link {\n padding: 2px 4px;\n border: 0;\n background: none;\n color: var(--ap-accent);\n text-decoration: underline;\n font-size: 13px;\n}\n\n.ap-primary:disabled,\n.ap-secondary:disabled,\n.ap-link:disabled {\n opacity: 0.6;\n cursor: default;\n}\n\n.ap-primary:focus-visible,\n.ap-secondary:focus-visible,\n.ap-link:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 2px;\n}\n\n/* ----------------------------------------------------------------------------\n The failures.\n\n They are RED, at the top of the block concerned, and carry the message the\n server returned as it stands: that is how a non-technical team learns that\n its remark is not saved, instead of believing it is.\n ---------------------------------------------------------------------------- */\n\n.ap-error {\n margin: 8px 0;\n padding: 10px 12px;\n border: 1px solid var(--ap-alert-border);\n border-radius: var(--ap-radius);\n background: var(--ap-alert-bg);\n color: var(--ap-alert-text);\n}\n\n.ap-error-title {\n font-weight: 700;\n margin-bottom: 4px;\n}\n\n.ap-error-detail {\n margin: 6px 0 0;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n font-size: 13px;\n}\n\n.ap-error .ap-link {\n color: var(--ap-alert-text);\n}\n\n/* ----------------------------------------------------------------------------\n Narrow: the panel takes the full width, and so does the form.\n ---------------------------------------------------------------------------- */\n\n/* ----------------------------------------------------------------------------\n Narrow.\n\n DEFECT OBSERVED at 375 px wide: a panel taking the full height covers the\n whole page, and no element can be pointed at any more -- every click lands\n on the panel. So it becomes a bottom band, which leaves the top half of\n the viewport free; one scrolls the page there to bring the wanted element\n into view. The form, for its part, hides the panel while typing (see\n notes.js): on a screen that size, writing and reading the list at the same\n time does not hold.\n ---------------------------------------------------------------------------- */\n\n/* On a narrow screen the panel becomes a bottom band and the form takes the\n full width.\n\n THE WIDTH CEILING IS KEPT, and it comes from a measured defect: \"left: 8;\n right: 8\" sizes the element against its CONTAINING BLOCK, which the host\n site's horizontal overflow can make wider than the visible window.\n Measured, in mobile emulation at 390 px: the site overflows to 407 px\n (with the tool and without it), and the panel came out 391 px wide\n starting at 8, that is 9 px off screen. \"100vw\" is the window, not the\n containing block: the ceiling therefore does nothing when the site does\n not overflow, and pulls the width back when it does. */\n@media (max-width: 560px) {\n .ap-panel {\n top: auto;\n right: 8px;\n left: 8px;\n bottom: 66px;\n height: 52vh;\n width: auto;\n max-width: calc(100vw - 16px);\n }\n\n /* A band spanning the width has no side, so the choice is inert here and\n the button says so by not being there. Offering a control that visibly\n does nothing is worse than offering none. The stored side is untouched:\n it is waiting for the wide screen it was chosen on. */\n .ap-side-toggle {\n display: none;\n }\n\n .ap-form {\n left: 8px;\n right: 8px;\n width: auto;\n max-width: calc(100vw - 16px);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ap-button {\n transition: none;\n }\n}\n\n/* The failure shows without opening the panel: the button's dot changes\n colour. A team that does not click must be able to see that something is\n wrong. */\n.ap-button.ap-failed .ap-button-dot {\n background: var(--ap-alert-text);\n}\n\n.ap-button.ap-failed {\n border-color: var(--ap-alert-border);\n}\n\n/* Signature reminder, in the note form.\n The name was shown at the foot of the panel only: invisible at the moment\n one writes. A user reported not knowing which name they were writing\n under. */\n.ap-form-signature {\n display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;\n margin: 0 0 .6rem; font-size: .85rem; opacity: .8;\n}\n\n/* Resolution state, said on the card.\n Two cases NOT to be confused: resolved and online, resolved but not\n deployed yet. The second keeps the defect on the reviewer's screen; hiding\n it or announcing it as fixed would cost them their trust in the tool. */\n.ap-state-mark {\n display: inline-block; margin: 0 0 .5rem;\n padding: .15rem .55rem; border-radius: 4px;\n font-size: .75rem; font-weight: 600; letter-spacing: .02em;\n}\n.ap-note.ap-resolved { opacity: .72; }\n.ap-note.ap-resolved .ap-state-mark {\n color: var(--ap-done-ink); background: var(--ap-done-veil);\n}\n.ap-note.ap-resolved-pending .ap-state-mark {\n color: var(--ap-pending-ink); background: var(--ap-pending-veil);\n}\n/* The \"it is fixed\" / \"reopen\" block, opened under the card. Same shape as\n the reply block: it is the same gesture, one answers a remark. */\n.ap-resolve,\n.ap-reply-form {\n margin-top: .6rem;\n padding-top: .6rem;\n border-top: 1px solid var(--ap-border);\n}\n\n/* The question asked before the key is dropped, at the foot of the list.\n Framed like the resolution block -- it is the same shape of gesture, one\n answers before something changes -- and set apart from the notes above it,\n because it is not about a note. */\n.ap-forget {\n margin-top: 1rem;\n padding-top: .6rem;\n border-top: 1px solid var(--ap-border);\n}\n\n.ap-forget .ap-actions {\n margin-top: .5rem;\n}\n\n.ap-history-toggle {\n display: block; width: 100%; margin: 1rem 0 .25rem;\n padding: .5rem .75rem; border: 1px dashed currentColor; border-radius: 6px;\n background: none; color: inherit; font: inherit; opacity: .7; cursor: pointer;\n}\n.ap-history-toggle:hover { opacity: 1; }\n\n\n/* ----------------------------------------------------------------------------\n Setup and pasting the salt.\n\n These are the only screens where something is copied by hand. Everything\n there is SELECTABLE and monospaced: a 43-character salt copied wrong\n cannot be recovered, and nothing helps less than a font that confuses I, l\n and 1.\n ---------------------------------------------------------------------------- */\n\n.ap-panel-wide {\n width: 560px;\n}\n\n.ap-copy {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n margin: 0 0 12px;\n}\n\n.ap-code {\n flex: 1 1 auto;\n width: 100%;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: 8px;\n background: var(--ap-bg-soft);\n color: var(--ap-text);\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, \"Liberation Mono\",\n monospace;\n font-size: 12.5px;\n line-height: 1.5;\n resize: vertical;\n white-space: pre;\n overflow-x: auto;\n}\n\n.ap-code:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 1px;\n}\n\n@media (max-width: 560px) {\n .ap-panel-wide {\n width: auto;\n }\n\n .ap-copy {\n flex-direction: column;\n }\n}\n";
|
|
21
|
+
const STYLES = "/* ============================================================================\n styles.css -- THE STYLES OF THE TOOL, AND OF NO OTHER ELEMENT.\n\n This sheet is INLINED into the served file by the build, then put into the\n tool's shadow root -- as a constructed sheet when the browser can do it, in\n a <style> otherwise. It was loaded by a <link> in the original tool; the\n move to a CDN under SRI brought it inside the file, so that there is only\n one digest to keep up to date. The containment itself has not changed, and\n is still twofold:\n\n - from the tool towards the site: no rule from here can reach an element\n of the host site, the browser sees to that. That is what makes the\n claim \"the layer touches nothing\" checkable rather than promised;\n - from the site towards the tool: no rule of the site can reach an\n element here. A redesign of the site's stylesheet therefore cannot\n distort the tool, nor the other way round.\n\n The \"ap-\" prefix on every class is the third safeguard: the day somebody\n loads these styles WITHOUT a shadow root -- by mistake, or to debug --\n nothing would answer a selector of the site.\n\n NO RULE TARGETS html, body, * OR ANY SELECTOR OF THE SITE. That is the one\n absolute prohibition of this file.\n\n COLOURS: the tool has its OWN palette, defined on the shadow root. It\n reads neither the site's variables nor its theme attribute: it has no\n reason to know how the site names its colours, and it must stay readable\n on a light site as on a dark one. The switch follows the system\n preference, the only information the tool has without asking anyone.\n ============================================================================ */\n\n\n:host {\n --ap-bg: #ffffff;\n --ap-bg-soft: #f4f6f8;\n --ap-bg-raised: #e9edf2;\n --ap-text: #1a1d21;\n --ap-text-soft: #5b6570;\n --ap-border: #d5dbe2;\n --ap-accent: #2f6fed;\n --ap-accent-dark: #1d55c8;\n --ap-accent-text: #ffffff;\n --ap-accent-veil: rgba(47, 111, 237, 0.14);\n --ap-alert-bg: #fdeceb;\n --ap-alert-border: #e3a9a4;\n --ap-alert-text: #8a1f16;\n /* THE TWO STATES A REMARK CAN BE IN ONCE IT IS ANSWERED, as tokens rather\n than as literals. They were literals, written once inside the card's\n state mark -- which meant the dark theme drew them at the LIGHT theme's\n ink: measured, 2.42:1 for \"resolved\" and 2.02:1 against the veil they\n sit on, where WCAG 1.4.3 asks 4.5. Below they are 4.68 and 5.23 in the\n light theme, 6.43 and 6.64 in the dark one, on the same composite.\n\n `pending` is the state that must never be mistaken for done: resolved,\n but not deployed -- the defect is still on the reader's screen. `fill`\n is the same colour asked to carry --ap-accent-text on top of it, for the\n badge on the page: 5.93:1 in light, 10.14:1 in dark. */\n --ap-done-ink: #0f7a52;\n --ap-done-veil: rgba(16, 185, 129, 0.14);\n --ap-pending-ink: #8a5a00;\n --ap-pending-veil: rgba(245, 158, 11, 0.16);\n --ap-pending-fill: #8a5a00;\n --ap-shadow: 0 6px 24px rgba(16, 24, 40, 0.18);\n --ap-radius: 10px;\n --ap-font: system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\",\n Arial, sans-serif;\n}\n\n@media (prefers-color-scheme: dark) {\n :host {\n --ap-bg: #1d2126;\n --ap-bg-soft: #262b32;\n --ap-bg-raised: #323942;\n --ap-text: #e9ecf0;\n --ap-text-soft: #a4adb8;\n --ap-border: #3a424c;\n --ap-accent: #6d9bff;\n --ap-accent-dark: #8fb4ff;\n --ap-accent-text: #10151c;\n --ap-accent-veil: rgba(109, 155, 255, 0.18);\n --ap-alert-bg: #3a1f1c;\n --ap-alert-border: #7c3a33;\n --ap-alert-text: #ffb9b1;\n --ap-done-ink: #56d3a0;\n --ap-done-veil: rgba(16, 185, 129, 0.18);\n --ap-pending-ink: #f0b757;\n --ap-pending-veil: rgba(245, 158, 11, 0.16);\n --ap-pending-fill: #f0b757;\n --ap-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);\n }\n}\n\n/* ----------------------------------------------------------------------------\n The layer.\n\n It covers the viewport and receives NO click: that is what lets the page\n behave exactly as usual as long as the tool is not in annotation mode.\n Each widget re-enables clicks for itself alone.\n ---------------------------------------------------------------------------- */\n\n.ap-layer {\n position: absolute;\n inset: 0;\n pointer-events: none;\n font-family: var(--ap-font);\n font-size: 14px;\n line-height: 1.45;\n color: var(--ap-text);\n text-align: left;\n -webkit-font-smoothing: antialiased;\n}\n\n.ap-layer button,\n.ap-layer input,\n.ap-layer textarea {\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n color: inherit;\n margin: 0;\n box-sizing: border-box;\n}\n\n/* ----------------------------------------------------------------------------\n The button: the only thing visible when the tool is at rest.\n ---------------------------------------------------------------------------- */\n\n.ap-button {\n position: fixed;\n right: 16px;\n bottom: 16px;\n display: inline-flex;\n align-items: center;\n gap: 8px;\n padding: 9px 14px;\n border: 1px solid var(--ap-border);\n border-radius: 999px;\n background: var(--ap-bg);\n color: var(--ap-text);\n box-shadow: var(--ap-shadow);\n cursor: pointer;\n pointer-events: auto;\n opacity: 0.92;\n transition: opacity 0.15s ease, transform 0.15s ease;\n}\n\n.ap-button:hover,\n.ap-button:focus-visible {\n opacity: 1;\n transform: translateY(-1px);\n}\n\n.ap-button:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 2px;\n}\n\n.ap-button[aria-pressed=\"true\"] {\n background: var(--ap-accent);\n border-color: var(--ap-accent);\n color: var(--ap-accent-text);\n opacity: 1;\n}\n\n.ap-button-dot {\n display: inline-block;\n width: 8px;\n height: 8px;\n border-radius: 50%;\n background: var(--ap-accent);\n flex: none;\n}\n\n.ap-button[aria-pressed=\"true\"] .ap-button-dot {\n background: var(--ap-accent-text);\n}\n\n.ap-button-count {\n padding: 1px 7px;\n border-radius: 999px;\n background: var(--ap-bg-raised);\n color: var(--ap-text-soft);\n font-size: 12px;\n}\n\n.ap-button[aria-pressed=\"true\"] .ap-button-count {\n background: rgba(255, 255, 255, 0.22);\n color: var(--ap-accent-text);\n}\n\n/* ----------------------------------------------------------------------------\n The pointing highlight.\n\n It is DRAWN HERE, from the coordinates of the element being pointed at.\n Nothing is put on the element itself: no class, no attribute, no style. So\n the site cannot move by a single pixel because of the pointing.\n ---------------------------------------------------------------------------- */\n\n.ap-highlight {\n position: fixed;\n border: 2px solid var(--ap-accent);\n border-radius: 3px;\n background: var(--ap-accent-veil);\n pointer-events: none;\n display: none;\n}\n\n.ap-highlight-label {\n position: fixed;\n max-width: 320px;\n padding: 4px 8px;\n border-radius: 6px;\n background: var(--ap-accent);\n color: var(--ap-accent-text);\n font-size: 12px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n pointer-events: none;\n display: none;\n box-shadow: var(--ap-shadow);\n}\n\n/* ----------------------------------------------------------------------------\n The zones a remark can be written in (data-zone), while annotation mode is on.\n\n DISCREET ON PURPOSE: a dashed line and no fill. The page under review is\n what the reviewer is reading, and a veil over every open area would tint\n the very colours they may be writing about. Drawn from coordinates, like\n the highlight: nothing is put on the site's element.\n ---------------------------------------------------------------------------- */\n\n.ap-zone {\n position: fixed;\n border: 1px dashed var(--ap-accent);\n border-radius: 4px;\n opacity: 0.6;\n pointer-events: none;\n box-sizing: border-box;\n}\n\n.ap-zone-notice {\n position: fixed;\n max-width: 280px;\n padding: 6px 10px;\n border: 1px solid var(--ap-border);\n border-radius: 6px;\n background: var(--ap-bg);\n color: var(--ap-text);\n font-size: 13px;\n box-shadow: var(--ap-shadow);\n pointer-events: none;\n display: none;\n}\n\n/* ----------------------------------------------------------------------------\n The markers: \"there are already notes here\".\n ---------------------------------------------------------------------------- */\n\n.ap-marker {\n position: fixed;\n min-width: 22px;\n height: 22px;\n padding: 0 6px;\n border: 2px solid var(--ap-bg);\n border-radius: 999px;\n background: var(--ap-accent);\n color: var(--ap-accent-text);\n font-size: 12px;\n font-weight: 700;\n line-height: 18px;\n text-align: center;\n cursor: pointer;\n pointer-events: auto;\n box-shadow: var(--ap-shadow);\n}\n\n/* THE STATE, IN THE BADGE ITSELF. The rule above is the OPEN state -- work to\n do -- and it stays the tool's accent, because that is what a badge on a page\n has always meant here. The other two are read against it:\n\n pending filled amber. Resolved, not deployed: the defect is still on the\n screen the reader is looking at, and it is the one state worth\n catching an eye that was not looking for it.\n done hollow, in the soft ink. History: there, countable, and not\n asking for anything.\n\n THE COLOUR IS NEVER ALONE. The count is written in the badge and the state\n is spelled out in its accessible name -- a badge that said \"still to fix\"\n by hue only would say nothing at all to a good part of its readers. */\n.ap-marker-pending {\n background: var(--ap-pending-fill);\n}\n.ap-marker-done {\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-weight: 600;\n /* The 2px border is the halo against the page and cannot be spent on the\n outline, so the outline is drawn inside. */\n box-shadow: var(--ap-shadow), inset 0 0 0 1px var(--ap-border);\n}\n\n.ap-marker:focus-visible {\n outline: 2px solid var(--ap-accent-dark);\n outline-offset: 2px;\n}\n\n/* ----------------------------------------------------------------------------\n The panel.\n ---------------------------------------------------------------------------- */\n\n.ap-panel {\n position: fixed;\n top: 12px;\n right: 12px;\n bottom: 72px;\n width: 360px;\n max-width: calc(100vw - 24px);\n display: none;\n flex-direction: column;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg);\n box-shadow: var(--ap-shadow);\n pointer-events: auto;\n overflow: hidden;\n}\n\n.ap-panel.ap-open {\n display: flex;\n}\n\n/* The other side. Two positions, right and left, and no third one: in\n annotation mode the layer takes every click, so every pixel of panel is a\n pixel of page that can no longer be pointed at. A floating panel would\n only move that loss around.\n\n \"bottom\" IS NOT REDECLARED, on purpose: the panel keeps the same 72 px of\n clearance above the floating button either way, and that clearance is the\n same on both sides because the button moves WITH it.\n\n AND THE BUTTON MOVES WITH IT, which was decided the other way first. The\n argument for leaving it was that it is the tool's only visible trace at\n rest, so an anchor that moved would stop being one. The owner's answer,\n and it is the better one: \"move left\" is asked of the TOOL, not of half of\n it. A panel on one edge and the control that opens it on the other makes\n the eye cross the whole window for one gesture, and somebody who set the\n side set it for the tool.\n\n TWO THINGS THIS RULE DEPENDS ON, both fragile:\n - it is written with ONE class, so it weighs exactly what \".ap-panel\"\n weighs;\n - it is written BEFORE the narrow block below.\n Reverse either and it wins under 560 px, where the panel is a bottom band\n spanning the width -- and a panel pinned to the left there is the full-\n height panel whose defect at 375 px is described in that block. */\n.ap-left {\n right: auto;\n left: 12px;\n}\n/* The button follows, and it is put on the LAYER and not on the panel: the\n button is not inside the panel, so the side has to be readable from a\n common ancestor. Same offset mirrored, same bottom -- only the edge\n changes. */\n.ap-layer.ap-left-side .ap-button {\n right: auto;\n left: 16px;\n}\n\n/* ----------------------------------------------------------------------------\n DOCKED (the `container` option): the panel FILLS the element the host page\n handed over, and there is no floating button -- the page opens and closes the\n tool. One class, added only when `container` is set (buildUi), so none of the\n floating layout above is touched without it.\n\n Two classes of specificity, so it wins over the edge-card rules and over the\n narrow-screen bottom band below: inside a container, the container's own box\n is what decides the size, not the viewport. The markers, the highlight and\n the pointing stay viewport-fixed and are untouched here -- only the panel\n moves from a floating card to a fill.\n ---------------------------------------------------------------------------- */\n.ap-docked .ap-button { display: none; }\n.ap-docked .ap-side-toggle { display: none; }\n.ap-docked .ap-panel {\n position: absolute;\n inset: 0;\n width: auto;\n max-width: none;\n border: 0;\n border-radius: 0;\n box-shadow: none;\n}\n\n.ap-panel-header {\n display: flex;\n align-items: baseline;\n gap: 8px;\n padding: 12px 14px;\n border-bottom: 1px solid var(--ap-border);\n background: var(--ap-bg-soft);\n}\n\n.ap-panel-title {\n font-size: 15px;\n font-weight: 600;\n flex: 1 1 auto;\n}\n\n/* -- what the whole project holds ---------------------------------------\n THE FIRST LINE OF THE FOOTER, on its own row. The footer is a flex row of\n short things -- a name, two buttons -- so this takes the whole width and the\n rest wraps under it. No ground and no border of its own: it is IN the footer,\n not beside it. */\n/* The retention line, when there is one. `:empty` rather than a class the\n script has to add and remove: the element is always there, and CSS decides\n whether it takes any room -- so a server that deletes nothing costs the\n panel exactly nothing. */\n.ap-panel-keeps { margin-top: 6px; color: var(--ap-text-soft); }\n.ap-panel-keeps:empty { display: none; }\n\n.ap-panel-footer { flex-wrap: wrap; }\n\n/* WHO YOU ARE SIGNING AS, ON A LINE OF ITS OWN. `flex-basis: 100%` is the same\n device the block above uses, and for the same reason: the footer is one\n wrapping row and everything in it was being strung end to end. */\n.ap-foot-who {\n flex-basis: 100%;\n display: flex; align-items: baseline; gap: 8px;\n}\n\n/* -- the list of remarks -------------------------------------------------\n A ROW, AND EVERY ROW IS A BUTTON. Not a card with a link in it: the whole\n line is the target, which is what a list of things to open should be, and it\n is reachable with a keyboard for free.\n\n THE EXCERPT TAKES THE ROOM AND FOLDS TO ONE LINE. What a remark is about can\n be a paragraph; what a list can show is a line. The author keeps a fixed\n place at the end so the eye can run down it. */\n.ap-row {\n display: flex; align-items: baseline; gap: 8px;\n width: 100%; margin: 0 0 4px; padding: 8px 10px;\n border: 1px solid var(--ap-border); border-radius: 8px;\n background: var(--ap-bg); color: var(--ap-text);\n font: inherit; text-align: left; cursor: pointer;\n transition: border-color .15s ease, background-color .15s ease;\n}\n.ap-row:hover { background: var(--ap-bg-soft); border-color: var(--ap-accent); }\n.ap-row:focus-visible { outline: 2px solid var(--ap-accent); outline-offset: 2px; }\n.ap-row-about {\n flex: 1; min-width: 0;\n overflow: hidden; text-overflow: ellipsis; white-space: nowrap;\n}\n.ap-row-who { flex: none; font-size: 12px; color: var(--ap-text-soft); }\n/* THE STATE, AS A DOT. Three of them, and the middle one is the one that must\n not read as done: resolved but not deployed is a defect still on screen. The\n accessible name spells all three out -- a colour is not a fact for\n everybody. */\n.ap-row-dot {\n flex: none; width: 8px; height: 8px; border-radius: 999px;\n background: var(--ap-accent); align-self: center;\n}\n.ap-row-pending .ap-row-dot { background: var(--ap-text-soft); }\n.ap-row-done .ap-row-dot { background: transparent; border: 1px solid var(--ap-border); }\n.ap-row-done .ap-row-about { color: var(--ap-text-soft); }\n@media (prefers-reduced-motion: reduce) { .ap-row { transition: none; } }\n\n/* -- a window that is not the panel --------------------------------------\n IT FLOATS OVER THE PAGE, and that is the point: the panel is a band down one\n edge, and what goes in here is not about the page beside it. Fixed rather\n than absolute -- the reader scrolls the page under it, and a window that\n scrolled away with the article would have to be chased.\n\n ABOVE THE PANEL AND BELOW NOTHING. It is opened from the panel's footer, so\n it must cover it; the tool's own layer already sits above the site.\n\n WIDTH: it is read, not filled in. 26rem is a paragraph, and min() keeps it\n inside a phone without a media query. */\n.ap-pop {\n position: fixed; z-index: 3;\n /* THE LAYER IS `pointer-events: none` so the site underneath keeps working,\n and every piece that must be reachable turns it back on. Without this\n line the window is a picture: no click on its buttons, and no drag on its\n bar -- which is exactly how it behaved when first measured. */\n pointer-events: auto;\n width: min(26rem, calc(100vw - 24px));\n max-height: calc(100vh - 24px);\n display: flex; flex-direction: column;\n border: 1px solid var(--ap-border); border-radius: 12px;\n background: var(--ap-bg); color: var(--ap-text);\n box-shadow: 0 18px 48px rgba(0, 0, 0, .22);\n overflow: hidden;\n}\n/* THE HANDLE. `touch-action: none` is what makes a finger drag the window\n instead of scrolling the page under it -- without it the browser claims the\n gesture before the first pointermove arrives. */\n.ap-pop-bar {\n display: flex; align-items: center; gap: 8px;\n padding: 8px 12px;\n border-bottom: 1px solid var(--ap-border);\n background: var(--ap-bg-soft);\n cursor: grab; touch-action: none; user-select: none;\n}\n.ap-pop-moving .ap-pop-bar { cursor: grabbing; }\n.ap-pop-title { flex: 1; font-size: 13px; font-weight: 650; }\n/* `min-height: 0` is what makes the scroll happen INSIDE the window rather\n than the window growing past its own height: a flex item does not shrink\n below its content without it, and the end of a long remark would be behind\n the bottom edge with nothing to scroll. */\n.ap-pop-body { flex: 1 1 auto; min-height: 0; padding: 12px; overflow: auto; }\n/* The one line that says why the page stayed where it was. Drawn as the panel\n draws its own help text, not as an alert: nothing has gone wrong. */\n.ap-why {\n margin: 0 0 10px; padding: 8px 10px;\n border-radius: 8px; background: var(--ap-bg-soft);\n color: var(--ap-text-soft); font-size: 12.5px;\n}\n/* THE CORNER, AND IT IS DRAWN RATHER THAN LEFT TO THE BROWSER. `resize: both`\n would have done this in one line and does nothing under a finger on iOS; the\n window is moved with pointer events for exactly that reason, and it is\n resized with them too. Two hairlines, the shape everybody already reads as a\n grip, in the same ink as the borders around it. */\n.ap-pop-grip {\n position: absolute; right: 0; bottom: 0;\n width: 18px; height: 18px;\n cursor: nwse-resize; touch-action: none;\n background:\n linear-gradient(135deg, transparent 42%, var(--ap-border) 42%,\n var(--ap-border) 54%, transparent 54%),\n linear-gradient(135deg, transparent 66%, var(--ap-border) 66%,\n var(--ap-border) 78%, transparent 78%);\n}\n.ap-pop-sizing { user-select: none; }\n.ap-pop-sizing .ap-pop-grip { cursor: nwse-resize; }\n/* Inside a window, the block is the window: no second frame around it. */\n.ap-pop-body .ap-config { margin: 0; padding: 0; border: 0; background: none; }\n.ap-pop-body .ap-forget { margin: 0; }\n.ap-pop-body .ap-panel-stats { margin: 0; }\n.ap-pop-body .ap-stats { margin: 0; }\n/* A WINDOW HAS ROOM, SO THE FILE GETS IT. In the panel this field was two or\n four lines because the column had nothing to spare; here it can show the\n whole thing without being scrolled. */\n.ap-pop-body .ap-code { min-height: 9.5em; }\n\n/* -- the file the assistant needs ---------------------------------------\n Drawn like the other block the panel opens in its body -- a title, a\n sentence, the thing itself, two buttons -- so nothing here is a new shape to\n learn. The last line is the warning, and it is a line and not a dialog: the\n reviewer asked for this file. */\n.ap-config {\n margin: 10px 0 0; padding: 12px;\n border: 1px solid var(--ap-border); border-radius: 10px;\n background: var(--ap-bg-soft);\n}\n/* The warning is a line at the tool's own soft ink, not in an alert colour:\n the reviewer asked for this file, they are not being warned off it. There is\n no --ap-warn token and this does not invent one. */\n.ap-config .ap-warn { margin-top: 10px; }\n.ap-panel-stats {\n flex-basis: 100%;\n display: flex; flex-wrap: wrap; gap: 4px 18px;\n margin-bottom: 4px;\n}\n.ap-stat { display: inline-flex; align-items: baseline; gap: 5px; }\n/* The row says what it counts, once, and the three figures follow it. Without\n it, \"3 / 2 / 1\" beside a panel about one page reads as being about that\n page. */\n.ap-stat-label {\n flex-basis: 100%; margin-bottom: 2px;\n font-size: 11px; font-weight: 650; letter-spacing: .02em;\n text-transform: uppercase; color: var(--ap-text-soft);\n}\n.ap-stat-n { font-size: 15px; font-weight: 650; color: var(--ap-text); }\n.ap-stat-w { font-size: 12px; color: var(--ap-text-soft); }\n/* UP TO THREE BLOCKS: this site, the server, every server. Each is a label and\n the figures it holds, and the figures are the same size in all three. */\n.ap-stats { display: flex; flex-direction: column; gap: 14px; }\n.ap-stats-block { display: flex; flex-direction: column; gap: 4px; }\n.ap-stats .ap-panel-stats { margin-bottom: 0; }\n/* What follows a label on its line -- \"updated daily\" -- is about the label,\n not part of it: lower case, lighter, after a dot. */\n.ap-stat-aside { font-weight: 400; letter-spacing: 0; text-transform: none; }\n.ap-stat-aside::before { content: \"\\00b7\"; margin: 0 6px; }\n/* THE LAST BLOCK IS NOT THIS SERVER'S. A soft ground sets it apart from the\n two above it, which are; nothing about it is larger. */\n.ap-stats-world {\n margin: 0 -8px; padding: 8px;\n background: var(--ap-bg-soft); border-radius: 8px;\n}\n.ap-panel-instructions {\n padding: 10px 14px;\n border-bottom: 1px solid var(--ap-border);\n color: var(--ap-text-soft);\n font-size: 13px;\n}\n\n.ap-panel-body {\n flex: 1 1 auto;\n overflow-y: auto;\n overscroll-behavior: contain;\n padding: 4px 14px 14px;\n}\n\n.ap-panel-footer {\n padding: 8px 14px;\n border-top: 1px solid var(--ap-border);\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-size: 12px;\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.ap-section-title {\n margin: 14px 0 6px;\n color: var(--ap-text-soft);\n font-size: 12px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n}\n\n.ap-section-help {\n margin: 0 0 8px;\n color: var(--ap-text-soft);\n font-size: 12px;\n}\n\n.ap-empty {\n margin: 16px 0;\n color: var(--ap-text-soft);\n}\n\n/* ----------------------------------------------------------------------------\n THE MODE BADGE: one word, drawn in both modes, at the top of every draw.\n\n It replaced a paragraph that only the public mode ever drew. Two things\n were wrong with that: secure mode said nothing, so the panel never told a\n reviewer which of the two they were in; and a paragraph pinned to the top\n for ever is skipped after the second reading, while a single word is not.\n\n IT IS NOT A BUTTON AND MUST NOT LOOK LIKE ONE. No shadow, no pressed\n state, cursor stays default: there is nothing to press. What it does have\n is a focus ring, because it takes focus -- the description below has to be\n reachable without a pointer, and that is the only reason it is focusable.\n ---------------------------------------------------------------------------- */\n\n.ap-mode {\n /* The frame the description is positioned against. It spans the width of\n the panel body, so a description pinned to its two edges cannot spill\n sideways out of a body that scrolls -- and a scrolling body clips both\n axes, not just the one it scrolls. */\n position: relative;\n margin: 4px 0 10px;\n}\n\n.ap-mode-chip {\n display: inline-block;\n padding: 2px 9px 3px;\n border: 1px solid var(--ap-border);\n border-radius: 999px;\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-size: 11px;\n font-weight: 600;\n letter-spacing: 0.05em;\n text-transform: uppercase;\n cursor: default;\n}\n\n/* The public badge is the one that carries a consequence, so it is the one\n that is coloured -- in the tool's own accent, not in the alert colours: a\n public key is a choice somebody made on purpose, not an incident. Secure\n keeps the quiet frame: it is the case where nothing is being said. */\n/* The same ring as every other focusable thing in the panel. It is the only\n visual proof, for somebody arriving by Tab, that this word is where their\n focus went. */\n.ap-mode-chip:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 2px;\n}\n\n/* Plain wears the same coat as public, and for the same reason: both are a\n choice somebody made on purpose, and both carry a consequence for whoever\n is about to write. Neither is an incident, so neither takes an alert\n colour. They cannot both be true at once. */\n.ap-mode-public .ap-mode-chip,\n.ap-mode-plain .ap-mode-chip {\n border-color: var(--ap-accent);\n background: var(--ap-accent-veil);\n color: var(--ap-accent-dark);\n}\n\n/* The description. Hidden by DEFAULT and shown on demand, and hidden in a way\n that leaves it readable to a screen reader: it is the badge's\n aria-describedby target, and an accessible description is computed from the\n referenced element whether or not it is painted. It is taken out of the\n layout entirely (absolute) so that showing it moves not one pixel of the\n list underneath -- a tooltip that pushes the notes down is a tooltip that\n makes people lose their place. */\n.ap-mode-tip {\n position: absolute;\n z-index: 2;\n top: calc(100% + 6px);\n left: 0;\n right: 0;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg-raised);\n color: var(--ap-text);\n box-shadow: var(--ap-shadow);\n font-size: 12px;\n font-weight: 400;\n letter-spacing: normal;\n text-transform: none;\n line-height: 1.45;\n opacity: 0;\n visibility: hidden;\n transform: translateY(-3px);\n transition: opacity 0.12s ease, transform 0.12s ease, visibility 0s linear 0.12s;\n pointer-events: none;\n}\n\n/* BOTH, and the keyboard one is not the afterthought: :focus-visible is what\n makes the sentence reachable by somebody who never touches a pointer. */\n.ap-mode-chip:hover ~ .ap-mode-tip,\n.ap-mode-chip:focus-visible ~ .ap-mode-tip {\n opacity: 1;\n visibility: visible;\n transform: none;\n transition: opacity 0.12s ease, transform 0.12s ease, visibility 0s;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ap-mode-tip {\n transform: none;\n transition: none;\n }\n .ap-mode-chip:hover ~ .ap-mode-tip,\n .ap-mode-chip:focus-visible ~ .ap-mode-tip {\n transition: none;\n }\n}\n\n/* The \"a newer client exists\" line and the \"this server speaks another\n format\" line are the same object on screen: a standing statement about what\n one is looking at, above the notes and above the failures. One rule, so\n they cannot drift apart -- and the second one joins it rather than\n inventing a colour, precisely because a protocol disagreement is a fact\n about the project, not an incident.\n\n Deliberately NOT the alert colours: neither is a failure, and an alarm that\n never goes away stops being read. */\n.ap-upgrade,\n.ap-format {\n margin: 0 0 10px;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-size: 12px;\n line-height: 1.45;\n}\n\n/* ----------------------------------------------------------------------------\n A note, and its replies.\n ---------------------------------------------------------------------------- */\n\n.ap-note {\n margin: 8px 0;\n padding: 10px 12px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg);\n}\n\n.ap-note.ap-orphan {\n background: var(--ap-bg-soft);\n}\n\n\n.ap-note-header {\n display: flex;\n align-items: baseline;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.ap-note-author {\n font-weight: 600;\n}\n\n.ap-note-date {\n color: var(--ap-text-soft);\n font-size: 12px;\n}\n\n.ap-note-target {\n margin: 4px 0 0;\n color: var(--ap-text-soft);\n font-size: 12px;\n font-style: italic;\n overflow-wrap: anywhere;\n}\n\n.ap-note-text {\n margin: 6px 0 0;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n\n.ap-note-actions {\n margin-top: 8px;\n display: flex;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.ap-replies {\n margin: 8px 0 0;\n padding-left: 10px;\n border-left: 2px solid var(--ap-border);\n}\n\n.ap-reply {\n margin: 8px 0 0;\n}\n\n/* ----------------------------------------------------------------------------\n The form, anchored near the element pointed at.\n ---------------------------------------------------------------------------- */\n\n.ap-form {\n position: fixed;\n width: 340px;\n max-width: calc(100vw - 24px);\n display: none;\n flex-direction: column;\n gap: 8px;\n padding: 14px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg);\n box-shadow: var(--ap-shadow);\n pointer-events: auto;\n}\n\n.ap-form.ap-open {\n display: flex;\n}\n\n/* THE NEW-REMARK FORM, SHOWN IN THE PANEL. Only in frame mode: the clicked\n element is in another document, so the form cannot float over it (decision\n A, FRAME-DESIGN). It is then a child of the panel and fills it, over the\n list, with the panel's own surface -- the panel is a positioning context\n (fixed when floating, absolute when docked), so inset:0 means \"fill it\".\n This class is never added in the ordinary tool, so none of the floating\n rules above move. */\n.ap-form-in-panel {\n position: absolute;\n inset: 0;\n width: auto;\n max-width: none;\n border: 0;\n border-radius: 0;\n box-shadow: none;\n overflow: auto;\n z-index: 2;\n}\n\n.ap-form-title {\n font-size: 15px;\n font-weight: 600;\n}\n\n.ap-form-target {\n color: var(--ap-text-soft);\n font-size: 12px;\n font-style: italic;\n overflow-wrap: anywhere;\n}\n\n.ap-label {\n display: block;\n margin-bottom: 3px;\n font-size: 12px;\n font-weight: 600;\n color: var(--ap-text-soft);\n}\n\n.ap-help {\n margin: 3px 0 0;\n font-size: 12px;\n color: var(--ap-text-soft);\n}\n\n.ap-field,\n.ap-area {\n width: 100%;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: 8px;\n background: var(--ap-bg-soft);\n color: var(--ap-text);\n}\n\n.ap-field:focus,\n.ap-area:focus {\n outline: 2px solid var(--ap-accent);\n outline-offset: 1px;\n}\n\n.ap-area {\n min-height: 92px;\n resize: vertical;\n}\n\n.ap-actions {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.ap-counter {\n margin-left: auto;\n font-size: 12px;\n color: var(--ap-text-soft);\n}\n\n/* ----------------------------------------------------------------------------\n Buttons.\n ---------------------------------------------------------------------------- */\n\n.ap-primary,\n.ap-secondary,\n.ap-link {\n border-radius: 8px;\n cursor: pointer;\n pointer-events: auto;\n}\n\n.ap-primary {\n padding: 8px 14px;\n border: 1px solid var(--ap-accent);\n background: var(--ap-accent);\n color: var(--ap-accent-text);\n font-weight: 600;\n}\n\n.ap-primary:hover {\n background: var(--ap-accent-dark);\n border-color: var(--ap-accent-dark);\n}\n\n.ap-secondary {\n padding: 8px 14px;\n border: 1px solid var(--ap-border);\n background: var(--ap-bg);\n color: var(--ap-text);\n}\n\n.ap-secondary:hover {\n background: var(--ap-bg-raised);\n}\n\n.ap-link {\n padding: 2px 4px;\n border: 0;\n background: none;\n color: var(--ap-accent);\n text-decoration: underline;\n font-size: 13px;\n}\n\n.ap-primary:disabled,\n.ap-secondary:disabled,\n.ap-link:disabled {\n opacity: 0.6;\n cursor: default;\n}\n\n.ap-primary:focus-visible,\n.ap-secondary:focus-visible,\n.ap-link:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 2px;\n}\n\n/* ----------------------------------------------------------------------------\n The failures.\n\n They are RED, at the top of the block concerned, and carry the message the\n server returned as it stands: that is how a non-technical team learns that\n its remark is not saved, instead of believing it is.\n ---------------------------------------------------------------------------- */\n\n.ap-error {\n margin: 8px 0;\n padding: 10px 12px;\n border: 1px solid var(--ap-alert-border);\n border-radius: var(--ap-radius);\n background: var(--ap-alert-bg);\n color: var(--ap-alert-text);\n}\n\n.ap-error-title {\n font-weight: 700;\n margin-bottom: 4px;\n}\n\n.ap-error-detail {\n margin: 6px 0 0;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n font-size: 13px;\n}\n\n.ap-error .ap-link {\n color: var(--ap-alert-text);\n}\n\n/* ----------------------------------------------------------------------------\n Narrow: the panel takes the full width, and so does the form.\n ---------------------------------------------------------------------------- */\n\n/* ----------------------------------------------------------------------------\n Narrow.\n\n DEFECT OBSERVED at 375 px wide: a panel taking the full height covers the\n whole page, and no element can be pointed at any more -- every click lands\n on the panel. So it becomes a bottom band, which leaves the top half of\n the viewport free; one scrolls the page there to bring the wanted element\n into view. The form, for its part, hides the panel while typing (see\n notes.js): on a screen that size, writing and reading the list at the same\n time does not hold.\n ---------------------------------------------------------------------------- */\n\n/* On a narrow screen the panel becomes a bottom band and the form takes the\n full width.\n\n THE WIDTH CEILING IS KEPT, and it comes from a measured defect: \"left: 8;\n right: 8\" sizes the element against its CONTAINING BLOCK, which the host\n site's horizontal overflow can make wider than the visible window.\n Measured, in mobile emulation at 390 px: the site overflows to 407 px\n (with the tool and without it), and the panel came out 391 px wide\n starting at 8, that is 9 px off screen. \"100vw\" is the window, not the\n containing block: the ceiling therefore does nothing when the site does\n not overflow, and pulls the width back when it does. */\n@media (max-width: 560px) {\n .ap-panel {\n top: auto;\n right: 8px;\n left: 8px;\n bottom: 66px;\n height: 52vh;\n width: auto;\n max-width: calc(100vw - 16px);\n }\n\n /* A band spanning the width has no side, so the choice is inert here and\n the button says so by not being there. Offering a control that visibly\n does nothing is worse than offering none. The stored side is untouched:\n it is waiting for the wide screen it was chosen on. */\n .ap-side-toggle {\n display: none;\n }\n\n .ap-form {\n left: 8px;\n right: 8px;\n width: auto;\n max-width: calc(100vw - 16px);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ap-button {\n transition: none;\n }\n}\n\n/* The failure shows without opening the panel: the button's dot changes\n colour. A team that does not click must be able to see that something is\n wrong. */\n.ap-button.ap-failed .ap-button-dot {\n background: var(--ap-alert-text);\n}\n\n.ap-button.ap-failed {\n border-color: var(--ap-alert-border);\n}\n\n/* Signature reminder, in the note form.\n The name was shown at the foot of the panel only: invisible at the moment\n one writes. A user reported not knowing which name they were writing\n under. */\n.ap-form-signature {\n display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;\n margin: 0 0 .6rem; font-size: .85rem; opacity: .8;\n}\n\n/* Resolution state, said on the card.\n Two cases NOT to be confused: resolved and online, resolved but not\n deployed yet. The second keeps the defect on the reviewer's screen; hiding\n it or announcing it as fixed would cost them their trust in the tool. */\n.ap-state-mark {\n display: inline-block; margin: 0 0 .5rem;\n padding: .15rem .55rem; border-radius: 4px;\n font-size: .75rem; font-weight: 600; letter-spacing: .02em;\n}\n.ap-note.ap-resolved { opacity: .72; }\n.ap-note.ap-resolved .ap-state-mark {\n color: var(--ap-done-ink); background: var(--ap-done-veil);\n}\n.ap-note.ap-resolved-pending .ap-state-mark {\n color: var(--ap-pending-ink); background: var(--ap-pending-veil);\n}\n/* The \"it is fixed\" / \"reopen\" block, opened under the card. Same shape as\n the reply block: it is the same gesture, one answers a remark. */\n.ap-resolve,\n.ap-reply-form {\n margin-top: .6rem;\n padding-top: .6rem;\n border-top: 1px solid var(--ap-border);\n}\n\n/* The question asked before the key is dropped, at the foot of the list.\n Framed like the resolution block -- it is the same shape of gesture, one\n answers before something changes -- and set apart from the notes above it,\n because it is not about a note. */\n.ap-forget {\n margin-top: 1rem;\n padding-top: .6rem;\n border-top: 1px solid var(--ap-border);\n}\n\n.ap-forget .ap-actions {\n margin-top: .5rem;\n}\n\n.ap-history-toggle {\n display: block; width: 100%; margin: 1rem 0 .25rem;\n padding: .5rem .75rem; border: 1px dashed currentColor; border-radius: 6px;\n background: none; color: inherit; font: inherit; opacity: .7; cursor: pointer;\n}\n.ap-history-toggle:hover { opacity: 1; }\n\n\n/* ----------------------------------------------------------------------------\n Setup and pasting the salt.\n\n These are the only screens where something is copied by hand. Everything\n there is SELECTABLE and monospaced: a 43-character salt copied wrong\n cannot be recovered, and nothing helps less than a font that confuses I, l\n and 1.\n ---------------------------------------------------------------------------- */\n\n.ap-panel-wide {\n width: 560px;\n}\n\n.ap-copy {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n margin: 0 0 12px;\n}\n\n.ap-code {\n flex: 1 1 auto;\n width: 100%;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: 8px;\n background: var(--ap-bg-soft);\n color: var(--ap-text);\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, \"Liberation Mono\",\n monospace;\n font-size: 12.5px;\n line-height: 1.5;\n resize: vertical;\n white-space: pre;\n overflow-x: auto;\n}\n\n.ap-code:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 1px;\n}\n\n@media (max-width: 560px) {\n .ap-panel-wide {\n width: auto;\n }\n\n .ap-copy {\n flex-direction: column;\n }\n}\n";
|
|
22
22
|
|
|
23
23
|
/* ==== 00-preamble.js ==== */
|
|
24
24
|
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
typo, and a typo that is ignored is a setting somebody believes they set. */
|
|
148
148
|
const SETTINGS = ['server', 'project', 'key', 'setup', 'mode', 'path',
|
|
149
149
|
'domains', 'version', 'environment', 'labels', 'zone', 'page',
|
|
150
|
-
'author', 'container'];
|
|
150
|
+
'author', 'container', 'publicnotice'];
|
|
151
151
|
|
|
152
152
|
/* THE OBJECT-ONLY OPTIONS. Each carries a live JavaScript value -- a function,
|
|
153
153
|
or an element -- that a data- attribute cannot hold and a tag therefore
|
|
@@ -258,7 +258,15 @@
|
|
|
258
258
|
every identity. The object-only options (OBJECT_OPTIONS: frame, onChange)
|
|
259
259
|
add NO member: they are left out of the identity on purpose, so that a page
|
|
260
260
|
wiring a callback or an iframe to the tool is not read as a second tool, and
|
|
261
|
-
a router re-executing its tag is still the same configuration.
|
|
261
|
+
a router re-executing its tag is still the same configuration.
|
|
262
|
+
|
|
263
|
+
STILL 4 WITH `publicnotice`. It is a setting (it can ride on the tag), but a
|
|
264
|
+
DISPLAY preference -- whether the panel shows the "this project is public"
|
|
265
|
+
warning -- and not a statement about which project runs here. So it is left
|
|
266
|
+
out of the identity exactly as `version` is (below, in the tag map and in
|
|
267
|
+
objectText): it adds no member, the format does not move, and two copies
|
|
268
|
+
that differ only by it are the same configuration. A release before it
|
|
269
|
+
existed reads this one's identity unchanged, and warns about no second tool. */
|
|
262
270
|
const IDENTITY_FORMAT = 'annotepage/identity/4';
|
|
263
271
|
const readableIdentity = (value) =>
|
|
264
272
|
typeof value === 'string' && value.indexOf('["' + IDENTITY_FORMAT + '",') === 0;
|
|
@@ -335,6 +343,10 @@
|
|
|
335
343
|
for (let i = 0; i < names.length; i += 1) {
|
|
336
344
|
const name = names[i];
|
|
337
345
|
if (name === 'version') continue;
|
|
346
|
+
/* A display preference, not a project: left out like `version`, so
|
|
347
|
+
a page that silences the public warning is not read as a second
|
|
348
|
+
tool and the identity format does not move (see IDENTITY_FORMAT). */
|
|
349
|
+
if (name === 'publicnotice') continue;
|
|
338
350
|
/* The object-only options are left out of the identity (see
|
|
339
351
|
OBJECT_OPTIONS): a page wiring a callback or an iframe to the tool
|
|
340
352
|
is the same configuration with or without them. `container` stays
|
|
@@ -359,7 +371,7 @@
|
|
|
359
371
|
|
|
360
372
|
const COPY_IDENTITY = JSON.stringify([IDENTITY_FORMAT,
|
|
361
373
|
SCRIPT_SRC.replace(/[?#].*$/, ''),
|
|
362
|
-
SETTINGS.filter((name) => name !== 'version').map((name) => (declaredIn(data, name)
|
|
374
|
+
SETTINGS.filter((name) => name !== 'version' && name !== 'publicnotice').map((name) => (declaredIn(data, name)
|
|
363
375
|
? settingText(name, name === 'setup' ? true : String(data[name])) : null)),
|
|
364
376
|
objectText(declaredConfig)]);
|
|
365
377
|
|
|
@@ -451,10 +463,18 @@
|
|
|
451
463
|
'"onChange" in window.annotepageConfig has to be a function. '
|
|
452
464
|
+ 'Nothing was read from it.');
|
|
453
465
|
} else if (name === 'frame') {
|
|
454
|
-
|
|
466
|
+
/* AN <iframe>, AND NOTHING ELSE. Any other element has no
|
|
467
|
+
contentWindow, so the head would have no window to pair the
|
|
468
|
+
bridge with -- and a bridge started against `undefined` pairs
|
|
469
|
+
with the FIRST window that speaks, whichever it is. The source
|
|
470
|
+
pin is the whole defence (a sealed frame has a null origin, so
|
|
471
|
+
origin cannot be the check); it must not be handed a non-frame
|
|
472
|
+
that quietly removes it. Refused by its tag name, the one thing
|
|
473
|
+
a div cannot fake. */
|
|
474
|
+
if (isElement(value) && value.tagName === 'IFRAME') pageHandles.frame = value;
|
|
455
475
|
else refuse('tag.config_element', { name: name },
|
|
456
|
-
'"frame" in window.annotepageConfig has to be an
|
|
457
|
-
+ '
|
|
476
|
+
'"frame" in window.annotepageConfig has to be an <iframe> '
|
|
477
|
+
+ 'element, the frame to annotate. Nothing was read from it.');
|
|
458
478
|
} else if (name === 'container' && isElement(value)) {
|
|
459
479
|
// The element form of container; its selector form falls through to
|
|
460
480
|
// the string branch below and is a setting like any other.
|
|
@@ -718,6 +738,18 @@
|
|
|
718
738
|
const DECLARED_AUTHOR = read('author');
|
|
719
739
|
const AUTHOR_FIXED = DECLARED_AUTHOR !== '';
|
|
720
740
|
|
|
741
|
+
/* PUBLICNOTICE -- whether the panel shows the "this project is public" warning,
|
|
742
|
+
the public badge drawn when the key is in the page (PUBLIC_KEY; see modeBadge
|
|
743
|
+
in 60-ui). ON by default: without it, the panel says exactly what it always
|
|
744
|
+
has. A host that gates the page itself -- a login in front of it -- turns it
|
|
745
|
+
OFF with `publicnotice="off"` (data-publicnotice, or `publicnotice` in the
|
|
746
|
+
object): the key is in the page as ever, but who may open the page is the
|
|
747
|
+
host's answer and not this notice's, so on such a site the warning misleads.
|
|
748
|
+
It touches ONLY that one warning -- the 'plain' and 'secure' badges are left
|
|
749
|
+
alone -- and it is a display preference, kept OUT of the config identity
|
|
750
|
+
(00-preamble, above). Read like `mode`: a value, lower-cased, matched. */
|
|
751
|
+
const PUBLIC_NOTICE = read('publicnotice').toLowerCase() !== 'off';
|
|
752
|
+
|
|
721
753
|
/* CONTAINER -- where the panel is drawn. An element handed in the object
|
|
722
754
|
(CONTAINER_EL), or a selector resolved against the document when the UI is
|
|
723
755
|
built (CONTAINER_SELECTOR). With neither, the panel floats as always.
|
|
@@ -730,6 +762,14 @@
|
|
|
730
762
|
const FRAME_EL = (!CONFIG_FAILURE && pageHandles.frame) || null;
|
|
731
763
|
const ON_CHANGE = (!CONFIG_FAILURE && pageHandles.onChange) || null;
|
|
732
764
|
|
|
765
|
+
/* THE ROLE this copy plays (see the bridge, 55-bridge). 'full' is the ordinary
|
|
766
|
+
tool, where the hands and the head are this one scope and the bridge is never
|
|
767
|
+
used. 'head' is the host side of frame mode: a panel that drives the page
|
|
768
|
+
inside the iframe given as `frame`. 'hands' is set by the companion
|
|
769
|
+
annotepage-frame.js running INSIDE that iframe, never here. A `let` because
|
|
770
|
+
the hands boot overwrites it, and nothing reads it before boot. */
|
|
771
|
+
let ROLE = FRAME_EL ? 'head' : 'full';
|
|
772
|
+
|
|
733
773
|
/* Note-taking context, DECLARED by the host site, never guessed. A
|
|
734
774
|
standalone tool cannot know how the site names its version; the site
|
|
735
775
|
does. Without these the fields stay empty: an invented version would send
|
|
@@ -2680,7 +2720,85 @@
|
|
|
2680
2720
|
return parts.join('|') + '/' + lost.join(',');
|
|
2681
2721
|
};
|
|
2682
2722
|
|
|
2683
|
-
/* ====
|
|
2723
|
+
/* ==== 55-bridge.js ==== */
|
|
2724
|
+
|
|
2725
|
+
/* -- 9 bis. The bridge between the hands and the head --------------------
|
|
2726
|
+
|
|
2727
|
+
The tool is one program in two halves (see ROLE, 00-preamble): the HANDS,
|
|
2728
|
+
which touch the page -- the pointing, the numbers, the highlight, the
|
|
2729
|
+
scrolling, and the anchoring that needs the DOM -- and the HEAD, which holds
|
|
2730
|
+
the panel, the keys, the server and the notes. In the ordinary tool ('full')
|
|
2731
|
+
both halves are THIS scope and call each other directly; the bridge below is
|
|
2732
|
+
never used.
|
|
2733
|
+
|
|
2734
|
+
In frame mode they are in two documents: the head in the host page, the hands
|
|
2735
|
+
inside a sealed iframe (sandbox allow-scripts, WITHOUT allow-same-origin).
|
|
2736
|
+
They share no scope, no storage and no DOM, so they speak only by
|
|
2737
|
+
postMessage, and this file is the whole of what crosses between them.
|
|
2738
|
+
|
|
2739
|
+
TWO RULES, both because the sealed iframe has a `null` origin -- there is no
|
|
2740
|
+
origin to name, so the origin is never used as a key:
|
|
2741
|
+
- a message is ours only if it carries our NAMESPACE;
|
|
2742
|
+
- it is from the other half only if its SOURCE WINDOW is the one we are
|
|
2743
|
+
paired with -- the iframe's contentWindow for the head, window.parent for
|
|
2744
|
+
the hands.
|
|
2745
|
+
Nothing structural is trusted from a message beyond a string `type` and a
|
|
2746
|
+
plain-data `data`; neither side ever runs what the other sends. */
|
|
2747
|
+
|
|
2748
|
+
const BRIDGE_NS = 'annotepage/bridge/1';
|
|
2749
|
+
|
|
2750
|
+
const bridgeHandlers = {};
|
|
2751
|
+
const onBridge = (type, fn) => { bridgeHandlers[type] = fn; };
|
|
2752
|
+
|
|
2753
|
+
let bridgePeer = null; // the window on the other side, once known
|
|
2754
|
+
let bridgeStarted = false;
|
|
2755
|
+
|
|
2756
|
+
/* The head knows its peer from the start -- the iframe's contentWindow. The
|
|
2757
|
+
hands learn theirs from the first message they receive, which is the
|
|
2758
|
+
parent. Either way it is a WINDOW, compared by identity, not by origin. */
|
|
2759
|
+
const bridgeConnect = (peer) => { bridgePeer = peer || null; };
|
|
2760
|
+
|
|
2761
|
+
const bridgeSend = (type, data) => {
|
|
2762
|
+
if (!bridgePeer) return;
|
|
2763
|
+
try {
|
|
2764
|
+
bridgePeer.postMessage(
|
|
2765
|
+
{ ns: BRIDGE_NS, type: type, data: data === undefined ? null : data },
|
|
2766
|
+
'*');
|
|
2767
|
+
} catch (e) {
|
|
2768
|
+
/* The other window is gone -- the iframe was removed, or the parent
|
|
2769
|
+
navigated away. There is nothing to say to it and nothing to do. */
|
|
2770
|
+
}
|
|
2771
|
+
};
|
|
2772
|
+
|
|
2773
|
+
/* `expectedPeer` is the only window a side will listen to: the iframe for the
|
|
2774
|
+
head, left null for the hands (which accept their parent as it first
|
|
2775
|
+
speaks, then pin to it). */
|
|
2776
|
+
const bridgeStart = (expectedPeer) => {
|
|
2777
|
+
if (bridgeStarted) return;
|
|
2778
|
+
bridgeStarted = true;
|
|
2779
|
+
window.addEventListener('message', (event) => {
|
|
2780
|
+
const msg = event.data;
|
|
2781
|
+
if (!msg || typeof msg !== 'object' || msg.ns !== BRIDGE_NS) return;
|
|
2782
|
+
if (expectedPeer && event.source !== expectedPeer) return;
|
|
2783
|
+
if (!bridgePeer) bridgePeer = event.source;
|
|
2784
|
+
else if (event.source !== bridgePeer) return;
|
|
2785
|
+
const fn = bridgeHandlers[msg.type];
|
|
2786
|
+
if (fn) fn(msg.data, event);
|
|
2787
|
+
});
|
|
2788
|
+
};
|
|
2789
|
+
|
|
2790
|
+
/* ==== 57-shell.js ==== */
|
|
2791
|
+
|
|
2792
|
+
/* ============================================================================
|
|
2793
|
+
57-shell.js -- THE SHELL BOTH HALVES BUILD.
|
|
2794
|
+
|
|
2795
|
+
The host element, its shadow root and the one layer inside it, plus the
|
|
2796
|
+
container controller. Shared because BOTH roles build a host-and-layer: the
|
|
2797
|
+
head builds the panel into it, the hands build the page overlay into it, and
|
|
2798
|
+
buildUi (role-gated, see its own note) decides which. In 'hands' the head
|
|
2799
|
+
branches of buildUi are never reached, so the head-only names they mention
|
|
2800
|
+
(toggleMode, applySide, ...) are never evaluated there.
|
|
2801
|
+
============================================================================ */
|
|
2684
2802
|
|
|
2685
2803
|
/* -- 13. Building the interface -------------------------------------------
|
|
2686
2804
|
Everything below lives in the shadow root. The host site sees none of it,
|
|
@@ -2803,6 +2921,14 @@
|
|
|
2803
2921
|
};
|
|
2804
2922
|
|
|
2805
2923
|
/** The interface. Built AFTER the labels: no fallback text to put in. */
|
|
2924
|
+
/* THE ONE LAYER, BUILT FOR THIS ROLE. In 'full' every branch is taken and the
|
|
2925
|
+
layer holds everything, exactly as the tool always has -- same elements, same
|
|
2926
|
+
order, so the floating stylesheet and the pixels are untouched. In 'head' the
|
|
2927
|
+
page-overlay pieces are skipped: the highlight, the numbers and the zone
|
|
2928
|
+
frames are drawn by the hands, in the iframe's own layer. In 'hands' it is the
|
|
2929
|
+
other way round: no button, no panel, no form -- only the overlay. The append
|
|
2930
|
+
ORDER is kept identical to the original for the full tool, so nothing about it
|
|
2931
|
+
can move a pixel. */
|
|
2806
2932
|
const buildUi = () => {
|
|
2807
2933
|
const layer = create('div', 'ap-layer');
|
|
2808
2934
|
// DOCKED (container option): the panel fills the host and there is no
|
|
@@ -2811,93 +2937,113 @@
|
|
|
2811
2937
|
if (dockEl) layer.classList.add('ap-docked');
|
|
2812
2938
|
root.appendChild(layer);
|
|
2813
2939
|
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
button
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
const zoneNotice = create('div', 'ap-zone-notice');
|
|
2834
|
-
zoneNotice.setAttribute('role', 'status');
|
|
2835
|
-
|
|
2836
|
-
/* -- pointing highlight -- */
|
|
2837
|
-
const highlight = create('div', 'ap-highlight');
|
|
2838
|
-
const label = create('div', 'ap-highlight-label');
|
|
2839
|
-
layer.appendChild(highlight);
|
|
2840
|
-
layer.appendChild(label);
|
|
2841
|
-
layer.appendChild(zoneNotice);
|
|
2842
|
-
|
|
2843
|
-
/* -- markers -- */
|
|
2844
|
-
const markers = create('div', 'ap-markers');
|
|
2845
|
-
layer.appendChild(markers);
|
|
2846
|
-
|
|
2847
|
-
/* -- panel -- */
|
|
2848
|
-
const panel = create('aside', 'ap-panel');
|
|
2849
|
-
panel.setAttribute('role', 'complementary');
|
|
2850
|
-
const header = create('div', 'ap-panel-header');
|
|
2851
|
-
const title = create('span', 'ap-panel-title', T('panel.title'));
|
|
2852
|
-
const close = create('button', 'ap-link', T('panel.close'));
|
|
2853
|
-
close.type = 'button';
|
|
2854
|
-
close.addEventListener('click', () => leaveMode());
|
|
2855
|
-
/* A REAL BUTTON, in the header, beside Close -- not a draggable title
|
|
2856
|
-
bar. A title bar reads as a title and not as a handle; without
|
|
2857
|
-
snapping, a dragged panel ends up crooked; and under a finger the drag
|
|
2858
|
-
fights the page's own scrolling. Being a button, it is reachable from
|
|
2859
|
-
the keyboard for free, which is why there is no shortcut for this:
|
|
2860
|
-
onKey is a capturing document listener and would fire while somebody
|
|
2861
|
-
is typing their remark in the textarea. */
|
|
2862
|
-
const sideToggle = create('button', 'ap-link ap-side-toggle');
|
|
2863
|
-
sideToggle.type = 'button';
|
|
2864
|
-
sideToggle.addEventListener('click', () => moveSide());
|
|
2865
|
-
header.appendChild(title);
|
|
2866
|
-
header.appendChild(sideToggle);
|
|
2867
|
-
header.appendChild(close);
|
|
2868
|
-
const instructions = create('div', 'ap-panel-instructions');
|
|
2869
|
-
/* With a zone, the sentence says where to click: frames on the page with
|
|
2870
|
-
nothing explaining them read as the site's own decoration. And the zone
|
|
2871
|
-
is judged HERE, once the tool exists on this page, so that a selector
|
|
2872
|
-
that does not parse is said in the console at load -- not on the day a
|
|
2873
|
-
reviewer first tries to click. */
|
|
2874
|
-
instructions.appendChild(create('div', null,
|
|
2875
|
-
T(judgeZone().declared ? 'panel.instructions_zone' : 'panel.instructions')));
|
|
2876
|
-
instructions.appendChild(create('div', null, T('panel.escape')));
|
|
2877
|
-
/* HOW LONG THIS SERVER KEEPS A THREAD, AND ONLY WHERE IT KEEPS ONE FOR A
|
|
2878
|
-
WHILE. "Nothing is ever deleted" is what this tool promises and what it
|
|
2879
|
-
does everywhere except on a server whose operator set an age -- and
|
|
2880
|
-
somebody about to write a remark is entitled to know their remark has a
|
|
2881
|
-
date on it. It goes here, at the top of the panel, read once when the
|
|
2882
|
-
panel opens: under the form it would be repeated at every remark, and
|
|
2883
|
-
behind a button it would be findable rather than said.
|
|
2884
|
-
|
|
2885
|
-
The element is created and left EMPTY when nothing expires, so the
|
|
2886
|
-
panel's own layout is identical on the servers that keep everything --
|
|
2887
|
-
which is all but one of them. */
|
|
2888
|
-
const keeps = create('div', 'ap-panel-keeps');
|
|
2889
|
-
instructions.appendChild(keeps);
|
|
2890
|
-
const body = create('div', 'ap-panel-body');
|
|
2891
|
-
const footer = create('div', 'ap-panel-footer');
|
|
2892
|
-
panel.appendChild(header);
|
|
2893
|
-
panel.appendChild(instructions);
|
|
2894
|
-
panel.appendChild(body);
|
|
2895
|
-
panel.appendChild(footer);
|
|
2896
|
-
layer.appendChild(panel);
|
|
2940
|
+
let button = null, buttonText = null, buttonCount = null;
|
|
2941
|
+
let zones = null, zoneNotice = null, highlight = null, label = null, markers = null;
|
|
2942
|
+
let panel = null, sideToggle = null, body = null, keeps = null, footer = null, form = null;
|
|
2943
|
+
|
|
2944
|
+
/* -- the button (head) -- */
|
|
2945
|
+
if (ROLE !== 'hands') {
|
|
2946
|
+
button = create('button', 'ap-button');
|
|
2947
|
+
button.type = 'button';
|
|
2948
|
+
button.setAttribute('aria-pressed', 'false');
|
|
2949
|
+
button.title = T('button.help');
|
|
2950
|
+
const dot = create('span', 'ap-button-dot');
|
|
2951
|
+
buttonText = create('span', null, T('button.open'));
|
|
2952
|
+
buttonCount = create('span', 'ap-button-count');
|
|
2953
|
+
button.appendChild(dot);
|
|
2954
|
+
button.appendChild(buttonText);
|
|
2955
|
+
button.appendChild(buttonCount);
|
|
2956
|
+
button.addEventListener('click', () => toggleMode());
|
|
2957
|
+
layer.appendChild(button);
|
|
2958
|
+
}
|
|
2897
2959
|
|
|
2898
|
-
/* --
|
|
2899
|
-
|
|
2900
|
-
|
|
2960
|
+
/* -- the page overlay (hands): zones, pointing highlight, markers --
|
|
2961
|
+
The zones come before the highlight, so that the outline of the element
|
|
2962
|
+
being pointed at is drawn over the frame of the zone that holds it. */
|
|
2963
|
+
if (ROLE !== 'head') {
|
|
2964
|
+
zones = create('div', 'ap-zones');
|
|
2965
|
+
layer.appendChild(zones);
|
|
2966
|
+
zoneNotice = create('div', 'ap-zone-notice');
|
|
2967
|
+
zoneNotice.setAttribute('role', 'status');
|
|
2968
|
+
|
|
2969
|
+
highlight = create('div', 'ap-highlight');
|
|
2970
|
+
label = create('div', 'ap-highlight-label');
|
|
2971
|
+
layer.appendChild(highlight);
|
|
2972
|
+
layer.appendChild(label);
|
|
2973
|
+
layer.appendChild(zoneNotice);
|
|
2974
|
+
|
|
2975
|
+
markers = create('div', 'ap-markers');
|
|
2976
|
+
layer.appendChild(markers);
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2979
|
+
/* -- the panel and the new-remark form (head) -- */
|
|
2980
|
+
if (ROLE !== 'hands') {
|
|
2981
|
+
panel = create('aside', 'ap-panel');
|
|
2982
|
+
panel.setAttribute('role', 'complementary');
|
|
2983
|
+
const header = create('div', 'ap-panel-header');
|
|
2984
|
+
const title = create('span', 'ap-panel-title', T('panel.title'));
|
|
2985
|
+
const close = create('button', 'ap-link', T('panel.close'));
|
|
2986
|
+
close.type = 'button';
|
|
2987
|
+
close.addEventListener('click', () => leaveMode());
|
|
2988
|
+
/* A REAL BUTTON, in the header, beside Close -- not a draggable title
|
|
2989
|
+
bar. A title bar reads as a title and not as a handle; without
|
|
2990
|
+
snapping, a dragged panel ends up crooked; and under a finger the drag
|
|
2991
|
+
fights the page's own scrolling. Being a button, it is reachable from
|
|
2992
|
+
the keyboard for free, which is why there is no shortcut for this:
|
|
2993
|
+
onKey is a capturing document listener and would fire while somebody
|
|
2994
|
+
is typing their remark in the textarea.
|
|
2995
|
+
|
|
2996
|
+
FLOATING ONLY. Docked (the `container` option), the panel fills the
|
|
2997
|
+
element the host handed over: there is no side for it to sit on, no
|
|
2998
|
+
floating button to follow it, and the move-left/right toggle means
|
|
2999
|
+
nothing. So it is not built at all when docked -- the stylesheet
|
|
3000
|
+
already hides it there (.ap-docked .ap-side-toggle), and applySide
|
|
3001
|
+
steps over a sideToggle that is not there. Without `container` this
|
|
3002
|
+
header is exactly what it always was: title, toggle, close. */
|
|
3003
|
+
header.appendChild(title);
|
|
3004
|
+
if (!dockEl) {
|
|
3005
|
+
sideToggle = create('button', 'ap-link ap-side-toggle');
|
|
3006
|
+
sideToggle.type = 'button';
|
|
3007
|
+
sideToggle.addEventListener('click', () => moveSide());
|
|
3008
|
+
header.appendChild(sideToggle);
|
|
3009
|
+
}
|
|
3010
|
+
header.appendChild(close);
|
|
3011
|
+
const instructions = create('div', 'ap-panel-instructions');
|
|
3012
|
+
/* With a zone, the sentence says where to click: frames on the page with
|
|
3013
|
+
nothing explaining them read as the site's own decoration. And the zone
|
|
3014
|
+
is judged HERE, once the tool exists on this page, so that a selector
|
|
3015
|
+
that does not parse is said in the console at load -- not on the day a
|
|
3016
|
+
reviewer first tries to click. */
|
|
3017
|
+
instructions.appendChild(create('div', null,
|
|
3018
|
+
T(judgeZone().declared ? 'panel.instructions_zone' : 'panel.instructions')));
|
|
3019
|
+
instructions.appendChild(create('div', null, T('panel.escape')));
|
|
3020
|
+
/* HOW LONG THIS SERVER KEEPS A THREAD, AND ONLY WHERE IT KEEPS ONE FOR A
|
|
3021
|
+
WHILE. "Nothing is ever deleted" is what this tool promises and what it
|
|
3022
|
+
does everywhere except on a server whose operator set an age -- and
|
|
3023
|
+
somebody about to write a remark is entitled to know their remark has a
|
|
3024
|
+
date on it. It goes here, at the top of the panel, read once when the
|
|
3025
|
+
panel opens: under the form it would be repeated at every remark, and
|
|
3026
|
+
behind a button it would be findable rather than said.
|
|
3027
|
+
|
|
3028
|
+
The element is created and left EMPTY when nothing expires, so the
|
|
3029
|
+
panel's own layout is identical on the servers that keep everything --
|
|
3030
|
+
which is all but one of them. */
|
|
3031
|
+
keeps = create('div', 'ap-panel-keeps');
|
|
3032
|
+
instructions.appendChild(keeps);
|
|
3033
|
+
body = create('div', 'ap-panel-body');
|
|
3034
|
+
footer = create('div', 'ap-panel-footer');
|
|
3035
|
+
panel.appendChild(header);
|
|
3036
|
+
panel.appendChild(instructions);
|
|
3037
|
+
panel.appendChild(body);
|
|
3038
|
+
panel.appendChild(footer);
|
|
3039
|
+
layer.appendChild(panel);
|
|
3040
|
+
|
|
3041
|
+
form = create('div', 'ap-form');
|
|
3042
|
+
// In head/frame mode the new-remark form lives IN the panel (decision
|
|
3043
|
+
// A), where it can fill it; in full mode it floats over the page, as a
|
|
3044
|
+
// layer child. 'full' keeps the layer, so nothing moves.
|
|
3045
|
+
(ROLE === 'head' ? panel : layer).appendChild(form);
|
|
3046
|
+
}
|
|
2901
3047
|
|
|
2902
3048
|
ui = {
|
|
2903
3049
|
layer: layer,
|
|
@@ -2917,7 +3063,7 @@
|
|
|
2917
3063
|
zoneNotice: zoneNotice
|
|
2918
3064
|
};
|
|
2919
3065
|
|
|
2920
|
-
applySide();
|
|
3066
|
+
if (ROLE !== 'hands') applySide();
|
|
2921
3067
|
if (dockEl) publishController();
|
|
2922
3068
|
};
|
|
2923
3069
|
|
|
@@ -2956,126 +3102,65 @@
|
|
|
2956
3102
|
}
|
|
2957
3103
|
};
|
|
2958
3104
|
|
|
2959
|
-
/*
|
|
2960
|
-
IN THE FOOTER, WHICH IS WHERE THE PANEL ALREADY KEEPS ITS STANDING FACTS:
|
|
2961
|
-
who you are, and what to do about the key. Three counts for the site are the
|
|
2962
|
-
same kind of thing -- context, not content -- and under the header they sat
|
|
2963
|
-
between the panel's title and its instructions, which is the path a reader
|
|
2964
|
-
takes to the notes themselves.
|
|
2965
|
-
|
|
2966
|
-
THREE NUMBERS, AND ONLY IF THE SERVER SENT THEM. `totals` is null against a
|
|
2967
|
-
server that does not know the field, and the row is then not drawn at all:
|
|
2968
|
-
showing three zeros would make an old server look like an empty project, and
|
|
2969
|
-
a tool that confuses those two teaches a reviewer to distrust what it says.
|
|
3105
|
+
/* ==== 58-hands.js ==== */
|
|
2970
3106
|
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
or not at all. */
|
|
2974
|
-
|
|
2975
|
-
const statsRow = () => {
|
|
2976
|
-
if (totals === null) return null;
|
|
2977
|
-
const rows = create('div', 'ap-stats');
|
|
2978
|
-
|
|
2979
|
-
/* ONE, AND THEN THE PLURAL. "1 pages" beside a figure the tool is asking
|
|
2980
|
-
to be believed reads as carelessness. The singular label is looked up
|
|
2981
|
-
first and English is the fallback for a translation that has not written
|
|
2982
|
-
one, which is the rule everywhere else here. */
|
|
2983
|
-
const figure = (n, word) => {
|
|
2984
|
-
const box = create('span', 'ap-stat');
|
|
2985
|
-
box.appendChild(create('span', 'ap-stat-n', readableNumber(n)));
|
|
2986
|
-
box.appendChild(create('span', 'ap-stat-w', T(n === 1 ? word + '_one' : word)));
|
|
2987
|
-
return box;
|
|
2988
|
-
};
|
|
3107
|
+
/* ============================================================================
|
|
3108
|
+
58-hands.js -- THE HANDS: everything that touches the annotated page.
|
|
2989
3109
|
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
const box = create('div', 'ap-stats-block');
|
|
2997
|
-
const head = create('span', 'ap-stat-label', T(label));
|
|
2998
|
-
if (aside) head.appendChild(create('span', 'ap-stat-aside', T(aside)));
|
|
2999
|
-
box.appendChild(head);
|
|
3000
|
-
const row = create('div', 'ap-panel-stats');
|
|
3001
|
-
box.appendChild(row);
|
|
3002
|
-
rows.appendChild(box);
|
|
3003
|
-
return { box: box, row: row };
|
|
3004
|
-
};
|
|
3110
|
+
The pointing highlight, the numbered markers, the zone outlines, the document
|
|
3111
|
+
pointer and key listeners, the scrolling, and the anchoring that needs a live
|
|
3112
|
+
DOM. This is the half that, in frame mode, runs INSIDE the sealed iframe
|
|
3113
|
+
(annotepage-frame.js is built from this file and the few it leans on); in the
|
|
3114
|
+
ordinary tool it is this same scope as the head, and the two call each other
|
|
3115
|
+
directly.
|
|
3005
3116
|
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
written. "Written" is in the label so that "still open" beside it reads
|
|
3011
|
-
as a part of it and not as a second count of the same thing. */
|
|
3012
|
-
const gone = expired !== null ? expired : { notes: 0, pages: 0 };
|
|
3117
|
+
The head half -- the panel, the keys, the server, the notes -- is 60-ui.js.
|
|
3118
|
+
What crosses between them when they are in two documents is the bridge,
|
|
3119
|
+
55-bridge.js, and nothing else.
|
|
3120
|
+
============================================================================ */
|
|
3013
3121
|
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3122
|
+
/* -- Hands-side plumbing (used only when the hands run apart, ROLE 'hands') --
|
|
3123
|
+
In 'full' and 'head' these are inert: handsZone is never read (judgeZone takes
|
|
3124
|
+
the preamble's zone), and the helpers below take their non-hands branch, which
|
|
3125
|
+
calls the head's own local functions exactly as before. */
|
|
3018
3126
|
|
|
3019
|
-
|
|
3020
|
-
Absent everywhere else -- see `publish_server_totals`, which is off until
|
|
3021
|
-
somebody writes it. Sites and notes: pages are a figure of the site,
|
|
3022
|
-
where the reader can see them. */
|
|
3023
|
-
if (serverWide !== null) {
|
|
3024
|
-
const all = block('panel.stats_server_label');
|
|
3025
|
-
all.row.appendChild(figure(serverWide.projects, 'panel.stats_sites'));
|
|
3026
|
-
all.row.appendChild(figure(serverWide.notes + serverWide.expiredNotes, 'panel.stats_written'));
|
|
3027
|
-
}
|
|
3127
|
+
let handsZone = null; // the zone the head sent with pick:on: { declared, selector }
|
|
3028
3128
|
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
if (
|
|
3040
|
-
everywhere.row.appendChild(figure(world.sites, 'panel.stats_sites'));
|
|
3041
|
-
}
|
|
3042
|
-
everywhere.row.appendChild(figure(world.notes, 'panel.stats_written'));
|
|
3129
|
+
/* The state of a group's badge. In 'hands' the group's notes are the ITEMS the
|
|
3130
|
+
head sent, each already carrying the state the head computed (noteState needs
|
|
3131
|
+
the site version, which is the head's); in 'full' they are the real notes and
|
|
3132
|
+
the head's groupState decides. */
|
|
3133
|
+
const markerGroupState = (list) => {
|
|
3134
|
+
if (ROLE !== 'hands') return groupState(list);
|
|
3135
|
+
let seen = 'done';
|
|
3136
|
+
for (let i = 0; i < list.length; i += 1) {
|
|
3137
|
+
const one = list[i].state || 'open';
|
|
3138
|
+
if (one === 'open') return 'open';
|
|
3139
|
+
if (one === 'pending') seen = 'pending';
|
|
3043
3140
|
}
|
|
3044
|
-
|
|
3045
|
-
return rows;
|
|
3141
|
+
return seen;
|
|
3046
3142
|
};
|
|
3047
3143
|
|
|
3048
|
-
/*
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
if (side === 'left') ui.panel.classList.add('ap-left');
|
|
3057
|
-
else ui.panel.classList.remove('ap-left');
|
|
3058
|
-
/* AND THE FLOATING BUTTON GOES WITH IT. It is not inside the panel, so
|
|
3059
|
-
the side is carried by the layer, which is the ancestor they share.
|
|
3060
|
-
Moving only the panel would put the control that opens it on the
|
|
3061
|
-
opposite edge from the thing it opens. */
|
|
3062
|
-
if (side === 'left') ui.layer.classList.add('ap-left-side');
|
|
3063
|
-
else ui.layer.classList.remove('ap-left-side');
|
|
3064
|
-
ui.sideToggle.textContent = side === 'left'
|
|
3065
|
-
? T('panel.move_right') : T('panel.move_left');
|
|
3144
|
+
/* A marker was tapped. In 'full' the head is right here and opens the window; in
|
|
3145
|
+
'hands' the window is in the host page, so the ids go over the bridge and the
|
|
3146
|
+
head opens it there. */
|
|
3147
|
+
const tapGroup = (group) => {
|
|
3148
|
+
if (ROLE !== 'hands') return showGroup(group);
|
|
3149
|
+
const ids = [];
|
|
3150
|
+
for (let i = 0; i < group.notes.length; i += 1) ids.push(group.notes[i].id);
|
|
3151
|
+
bridgeSend('tapped', { ids: ids });
|
|
3066
3152
|
};
|
|
3067
3153
|
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
if (target && document.contains(target)) positionForm(target);
|
|
3154
|
+
/* WHICH NOTES ARE ORPHANED, reported to the head so its panel can show them in
|
|
3155
|
+
the "not found on this page" section. Only the ids cross -- the head already
|
|
3156
|
+
holds the notes themselves (see FRAME-DESIGN, data model). */
|
|
3157
|
+
const reportAnchored = () => {
|
|
3158
|
+
const ids = [];
|
|
3159
|
+
for (let i = 0; i < orphans.length; i += 1) ids.push(orphans[i].id);
|
|
3160
|
+
bridgeSend('anchored', { orphanIds: ids });
|
|
3076
3161
|
};
|
|
3077
3162
|
|
|
3078
|
-
/* --
|
|
3163
|
+
/* -- The pointing highlight ---------------------------------------------- */
|
|
3079
3164
|
|
|
3080
3165
|
const place = (el, rect, margin) => {
|
|
3081
3166
|
const m = margin || 0;
|
|
@@ -3106,28 +3191,7 @@
|
|
|
3106
3191
|
ui.label.style.display = 'none';
|
|
3107
3192
|
};
|
|
3108
3193
|
|
|
3109
|
-
/*
|
|
3110
|
-
in the row, in the card and, the day the markers gained a colour, they would
|
|
3111
|
-
have been written a third time. The middle state is the one that must not be
|
|
3112
|
-
folded into the others: resolved but not deployed is a defect still on the
|
|
3113
|
-
reader's screen, and anything drawing it as done lies at a glance. */
|
|
3114
|
-
const noteState = (note) => {
|
|
3115
|
-
if (!note.resolved_at) return 'open';
|
|
3116
|
-
return alreadyDeployed(note.resolved_version) ? 'done' : 'pending';
|
|
3117
|
-
};
|
|
3118
|
-
|
|
3119
|
-
/* AND WHAT STATE A GROUP OF THEM IS IN: the most urgent one present. A badge
|
|
3120
|
-
that averaged its remarks would go quiet on an element still carrying an
|
|
3121
|
-
open one. */
|
|
3122
|
-
const groupState = (notes) => {
|
|
3123
|
-
let seen = 'done';
|
|
3124
|
-
for (let i = 0; i < notes.length; i += 1) {
|
|
3125
|
-
const one = noteState(notes[i]);
|
|
3126
|
-
if (one === 'open') return 'open';
|
|
3127
|
-
if (one === 'pending') seen = 'pending';
|
|
3128
|
-
}
|
|
3129
|
-
return seen;
|
|
3130
|
-
};
|
|
3194
|
+
/* -- The markers, the reposition loop, and the zone on the page --------- */
|
|
3131
3195
|
|
|
3132
3196
|
/** One badge per annotated element. It only appears in annotation mode:
|
|
3133
3197
|
outside that mode, the page is exactly the site's.
|
|
@@ -3143,6 +3207,53 @@
|
|
|
3143
3207
|
in the panel, which answers "where is it in the list" -- a question nobody
|
|
3144
3208
|
asks while pointing at the element itself. What they want is the remark,
|
|
3145
3209
|
and the window is where a remark is read. */
|
|
3210
|
+
/* WHERE A BADGE SITS, given the element's rectangle and the viewport size. The
|
|
3211
|
+
value returned is the badge's TOP-LEFT corner, in viewport pixels.
|
|
3212
|
+
|
|
3213
|
+
NORMALLY 8px up and to the left of the element's own top-left corner, kept on
|
|
3214
|
+
screen -- the exact position the tool has always drawn, so every page that
|
|
3215
|
+
already has badges keeps them to the pixel. It leans a little over the
|
|
3216
|
+
corner, in the element's margin, which reads as "this element".
|
|
3217
|
+
|
|
3218
|
+
THE EDGES ARE WHERE THAT BROKE. An element flush to the LEFT edge has r.left
|
|
3219
|
+
near 0, so r.left - 8 is negative; the old Math.max(2, ...) then drove the
|
|
3220
|
+
badge to x=2, flat onto the element's first glyphs -- "1exte". The TOP edge
|
|
3221
|
+
had the same fault downward. So when a margin has no room, the badge is
|
|
3222
|
+
lifted CLEAR of the text into the margin that does: hard against the left, it
|
|
3223
|
+
sits just ABOVE the element (its bottom meeting the element's top); hard
|
|
3224
|
+
against the top, just to its LEFT. The common, non-edge case is untouched.
|
|
3225
|
+
|
|
3226
|
+
A badge is about 28px (min-width/height 22px plus its 2px halo, .ap-marker),
|
|
3227
|
+
and 28 is already the reach the on-screen clamp below assumes (vw/vh - 30,
|
|
3228
|
+
two px shy of the edge). Lifting by it clears a 26px badge with room over --
|
|
3229
|
+
WHERE THERE IS ROOM. Against one edge and within ~28px of the other (a corner,
|
|
3230
|
+
in effect), there is nowhere that clears the text; the badge then lifts as far
|
|
3231
|
+
as the near edge allows, which is never lower than the old clamp and so never
|
|
3232
|
+
over more of the glyphs than before. Only the floating, open-margin case is
|
|
3233
|
+
promised to clear entirely -- which is the case the fix was reported for. */
|
|
3234
|
+
const badgePosition = (r, vw, vh) => {
|
|
3235
|
+
const BADGE = 28;
|
|
3236
|
+
const left = Math.min(r.left - 8, vw - 30);
|
|
3237
|
+
const top = Math.min(r.top - 8, vh - 30);
|
|
3238
|
+
const leftTight = left < 2; // the left margin has no room: would clamp on
|
|
3239
|
+
const topTight = top < 2; // the top margin has no room: would clamp on
|
|
3240
|
+
if (leftTight && !topTight) {
|
|
3241
|
+
// Lift into the margin above: the badge's bottom meets the element's
|
|
3242
|
+
// top when there is room, and as near it as the top edge allows when
|
|
3243
|
+
// the element is also close to the top -- never below the old position.
|
|
3244
|
+
return { left: 2, top: Math.max(2, Math.min(r.top - BADGE, vh - 30)) };
|
|
3245
|
+
}
|
|
3246
|
+
if (topTight && !leftTight) {
|
|
3247
|
+
// The same, into the margin to the left: its right meets the element's
|
|
3248
|
+
// left where there is room, and as near as the left edge allows.
|
|
3249
|
+
return { left: Math.max(2, Math.min(r.left - BADGE, vw - 30)), top: 2 };
|
|
3250
|
+
}
|
|
3251
|
+
/* Non-edge -- the overwhelming case -- is byte-for-byte the old result; and
|
|
3252
|
+
the degenerate top-left corner, where no margin has room at all, falls
|
|
3253
|
+
back on it too, there being nowhere clear to lift to. */
|
|
3254
|
+
return { left: Math.max(2, left), top: Math.max(2, top) };
|
|
3255
|
+
};
|
|
3256
|
+
|
|
3146
3257
|
const drawMarkers = () => {
|
|
3147
3258
|
// The zones move with the page exactly when the badges do.
|
|
3148
3259
|
drawZones();
|
|
@@ -3154,7 +3265,7 @@
|
|
|
3154
3265
|
if (r.width === 0 && r.height === 0) continue;
|
|
3155
3266
|
if (r.bottom < 0 || r.top > window.innerHeight) continue;
|
|
3156
3267
|
const n = group.notes.length;
|
|
3157
|
-
const state =
|
|
3268
|
+
const state = markerGroupState(group.notes);
|
|
3158
3269
|
const badge = create('button', 'ap-marker ap-marker-' + state, String(n));
|
|
3159
3270
|
badge.type = 'button';
|
|
3160
3271
|
const what = n === 1 ? T('marker.one') : T('marker.n', { n: n });
|
|
@@ -3163,9 +3274,10 @@
|
|
|
3163
3274
|
badge.title = what + ' \u2014 ' + how;
|
|
3164
3275
|
badge.setAttribute('aria-label', T('marker.open') + ' \u2014 ' + what
|
|
3165
3276
|
+ ' \u2014 ' + how);
|
|
3166
|
-
|
|
3167
|
-
badge.style.
|
|
3168
|
-
badge.
|
|
3277
|
+
const at = badgePosition(r, window.innerWidth, window.innerHeight);
|
|
3278
|
+
badge.style.left = at.left + 'px';
|
|
3279
|
+
badge.style.top = at.top + 'px';
|
|
3280
|
+
badge.addEventListener('click', ((g) => () => tapGroup(g))(group));
|
|
3169
3281
|
ui.markers.appendChild(badge);
|
|
3170
3282
|
}
|
|
3171
3283
|
};
|
|
@@ -3191,8 +3303,12 @@
|
|
|
3191
3303
|
anchor();
|
|
3192
3304
|
/* A note can also come BACK from the orphan list here: the page had not
|
|
3193
3305
|
finished rendering when we first looked, and now it has. That is a real
|
|
3194
|
-
change, and it is worth the redraw.
|
|
3195
|
-
|
|
3306
|
+
change, and it is worth the redraw. In 'hands' the panel is in the host
|
|
3307
|
+
page, so the change is reported and the head redraws it. */
|
|
3308
|
+
if (anchorSignature() !== before) {
|
|
3309
|
+
if (ROLE === 'hands') reportAnchored();
|
|
3310
|
+
else drawPanel();
|
|
3311
|
+
}
|
|
3196
3312
|
};
|
|
3197
3313
|
|
|
3198
3314
|
const refreshPositions = () => {
|
|
@@ -3211,7 +3327,9 @@
|
|
|
3211
3327
|
if (pickable(hovered)) showHighlight(hovered);
|
|
3212
3328
|
else hideHighlight();
|
|
3213
3329
|
}
|
|
3214
|
-
|
|
3330
|
+
// The new-remark form floats over its element only when it is in this
|
|
3331
|
+
// same document (full mode). In 'hands' the form is in the host panel.
|
|
3332
|
+
if (ROLE !== 'hands' && target && document.contains(target)) positionForm(target);
|
|
3215
3333
|
});
|
|
3216
3334
|
};
|
|
3217
3335
|
|
|
@@ -3235,8 +3353,11 @@
|
|
|
3235
3353
|
}
|
|
3236
3354
|
};
|
|
3237
3355
|
|
|
3238
|
-
/* Which setting to name in the console: the reader has one or the other.
|
|
3239
|
-
|
|
3356
|
+
/* Which setting to name in the console: the reader has one or the other. In
|
|
3357
|
+
'hands' the zone was set on the host page and sent over, so the console line
|
|
3358
|
+
(shown in the host page's console, where the head runs) names it as such. */
|
|
3359
|
+
const zoneSource = () => (ROLE === 'hands' ? 'the host page\'s zone'
|
|
3360
|
+
: (script ? 'data-zone' : 'zone in window.annotepageConfig'));
|
|
3240
3361
|
|
|
3241
3362
|
let zoneJudged = null;
|
|
3242
3363
|
let zoneMissingSaid = false;
|
|
@@ -3246,7 +3367,12 @@
|
|
|
3246
3367
|
line that says so is said once for the copy. */
|
|
3247
3368
|
const judgeZone = () => {
|
|
3248
3369
|
if (zoneJudged) return zoneJudged;
|
|
3249
|
-
|
|
3370
|
+
// In 'hands' the zone is whatever the head sent with pick:on; in 'full'/'head'
|
|
3371
|
+
// it is this page's own data-zone (00-preamble). The ternary keeps the
|
|
3372
|
+
// preamble names out of the hands build, where they do not exist.
|
|
3373
|
+
const declared = ROLE === 'hands' ? !!(handsZone && handsZone.declared) : ZONE_DECLARED;
|
|
3374
|
+
const selector = ROLE === 'hands' ? (handsZone ? handsZone.selector : '') : ZONE_SELECTOR;
|
|
3375
|
+
zoneJudged = zoneFrom(declared, selector, selectorCompiles);
|
|
3250
3376
|
if (zoneJudged.declared && !zoneJudged.valid) {
|
|
3251
3377
|
complain('the zone ' + JSON.stringify(zoneJudged.selector) + ' (' + zoneSource()
|
|
3252
3378
|
+ ') is not a valid CSS selector list: ' + JSON.stringify(zoneJudged.broken)
|
|
@@ -3288,53 +3414,583 @@
|
|
|
3288
3414
|
+ ') matches nothing on this page, so no remark can be written here. '
|
|
3289
3415
|
+ 'The notes already written are still shown.');
|
|
3290
3416
|
}
|
|
3291
|
-
return true;
|
|
3417
|
+
return true;
|
|
3418
|
+
};
|
|
3419
|
+
|
|
3420
|
+
/* CAPPED, because a selector is the site's to write and `p` matches hundreds:
|
|
3421
|
+
a frame per paragraph, redrawn at every frame of a scroll, is the tool
|
|
3422
|
+
making the page slow in order to decorate it. Document order puts an
|
|
3423
|
+
ancestor before what it contains, so the frames dropped are the last ones
|
|
3424
|
+
down the page -- and picking inside them still works. */
|
|
3425
|
+
const ZONES_DRAWN = 64;
|
|
3426
|
+
|
|
3427
|
+
const drawZones = () => {
|
|
3428
|
+
empty(ui.zones);
|
|
3429
|
+
if (!mode) return;
|
|
3430
|
+
const zone = judgeZone();
|
|
3431
|
+
if (!zone.declared || !zone.valid) return;
|
|
3432
|
+
const outer = outermostZones(zoneElements(), zone.selector);
|
|
3433
|
+
for (let i = 0, drawn = 0; i < outer.length && drawn < ZONES_DRAWN; i += 1) {
|
|
3434
|
+
const r = outer[i].getBoundingClientRect();
|
|
3435
|
+
if (r.width === 0 && r.height === 0) continue;
|
|
3436
|
+
if (r.bottom < 0 || r.top > window.innerHeight) continue;
|
|
3437
|
+
const frame = create('div', 'ap-zone');
|
|
3438
|
+
place(frame, r, 4);
|
|
3439
|
+
ui.zones.appendChild(frame);
|
|
3440
|
+
drawn += 1;
|
|
3441
|
+
}
|
|
3442
|
+
};
|
|
3443
|
+
|
|
3444
|
+
/* WHY NOTHING OPENED, next to the hand that clicked. A click outside the zone
|
|
3445
|
+
that did nothing at all would be read as a broken tool; a form refused in
|
|
3446
|
+
the panel, a whole band away, would not be read at all. It goes by itself:
|
|
3447
|
+
it answers one click, and the next click is the reader's. */
|
|
3448
|
+
const sayOutsideZone = (event, label) => {
|
|
3449
|
+
const notice = ui.zoneNotice;
|
|
3450
|
+
notice.textContent = T(label);
|
|
3451
|
+
notice.style.display = 'block';
|
|
3452
|
+
const x = typeof event.clientX === 'number' ? event.clientX : window.innerWidth / 2;
|
|
3453
|
+
const y = typeof event.clientY === 'number' ? event.clientY : window.innerHeight / 2;
|
|
3454
|
+
notice.style.left = Math.max(8, Math.min(x + 12, window.innerWidth - notice.offsetWidth - 8)) + 'px';
|
|
3455
|
+
notice.style.top = Math.max(8, Math.min(y + 16, window.innerHeight - notice.offsetHeight - 8)) + 'px';
|
|
3456
|
+
if (zoneNoticeTimer) window.clearTimeout(zoneNoticeTimer);
|
|
3457
|
+
zoneNoticeTimer = window.setTimeout(hideZoneNotice, 2600);
|
|
3458
|
+
};
|
|
3459
|
+
|
|
3460
|
+
const hideZoneNotice = () => {
|
|
3461
|
+
if (zoneNoticeTimer) window.clearTimeout(zoneNoticeTimer);
|
|
3462
|
+
zoneNoticeTimer = null;
|
|
3463
|
+
if (ui) ui.zoneNotice.style.display = 'none';
|
|
3464
|
+
};
|
|
3465
|
+
|
|
3466
|
+
/* -- Showing an element (scroll into view) ------------------------------ */
|
|
3467
|
+
|
|
3468
|
+
const showElement = (note) => {
|
|
3469
|
+
let el = null;
|
|
3470
|
+
for (let i = 0; i < anchored.length; i += 1) {
|
|
3471
|
+
if (anchored[i].notes.indexOf(note) !== -1) el = anchored[i].element;
|
|
3472
|
+
}
|
|
3473
|
+
if (!el || !document.contains(el)) return 'gone';
|
|
3474
|
+
const r = el.getBoundingClientRect();
|
|
3475
|
+
if (r.width === 0 && r.height === 0) return 'hidden';
|
|
3476
|
+
// scrollIntoView moves the viewpoint, never the document: no node, no
|
|
3477
|
+
// style of the site is touched.
|
|
3478
|
+
el.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
|
3479
|
+
window.setTimeout(() => {
|
|
3480
|
+
showHighlight(el);
|
|
3481
|
+
window.setTimeout(hideHighlight, 1400);
|
|
3482
|
+
}, 350);
|
|
3483
|
+
return 'scrolled';
|
|
3484
|
+
};
|
|
3485
|
+
|
|
3486
|
+
/* -- 17. Annotation mode ------------------------------------------------- */
|
|
3487
|
+
|
|
3488
|
+
/* NOTHING IS AIMED AT WHILE A WINDOW IS OPEN. Reading a remark with the
|
|
3489
|
+
pointer resting anywhere over the page meant the outline kept jumping from
|
|
3490
|
+
paragraph to paragraph behind the window, and the label with it -- the tool
|
|
3491
|
+
proposing the next thing to annotate to somebody who is busy reading the
|
|
3492
|
+
last one. Reported as exactly that: it is distracting.
|
|
3493
|
+
|
|
3494
|
+
The aim is FROZEN, not merely hidden: `hovered` is left where it was, so
|
|
3495
|
+
closing the window puts the reader back on the element they had, rather than
|
|
3496
|
+
on whatever happens to be under a pointer that has not moved. */
|
|
3497
|
+
|
|
3498
|
+
const onHover = (event) => {
|
|
3499
|
+
/* The aim is frozen while a window is open -- a head decision. In 'hands'
|
|
3500
|
+
the window is the head's, in another document, and this page does not
|
|
3501
|
+
know it is open; it keeps its aim (a documented divergence, FRAME-DESIGN
|
|
3502
|
+
hard problem 1). The guard applies only where the pop is this scope's. */
|
|
3503
|
+
if (ROLE !== 'hands' && pop) return;
|
|
3504
|
+
/* AND NOT WHILE A REMARK IS BEING WRITTEN, for the same reason and on the
|
|
3505
|
+
same report: the outline and its label kept moving from paragraph to
|
|
3506
|
+
paragraph behind the form, so the tool was proposing the next thing to
|
|
3507
|
+
annotate to somebody in the middle of annotating this one. The element
|
|
3508
|
+
being written about stays outlined until the form closes -- which is
|
|
3509
|
+
what a reader looking away from their own sentence needs to find.
|
|
3510
|
+
|
|
3511
|
+
In 'hands' there is no form in this document (it is in the host panel):
|
|
3512
|
+
ui.form is absent, and the guard simply does not apply here. */
|
|
3513
|
+
if (ui.form && ui.form.classList.contains('ap-open')) return;
|
|
3514
|
+
const el = event.target;
|
|
3515
|
+
if (!el || el.nodeType !== 1 || inTool(el)) return;
|
|
3516
|
+
if (el === document.body || el === document.documentElement) return;
|
|
3517
|
+
/* Outside the zone the aim goes out: an outline there offers a remark
|
|
3518
|
+
the click is going to refuse. */
|
|
3519
|
+
if (!pickable(el)) {
|
|
3520
|
+
hovered = null;
|
|
3521
|
+
hideHighlight();
|
|
3522
|
+
return;
|
|
3523
|
+
}
|
|
3524
|
+
hovered = el;
|
|
3525
|
+
showHighlight(el);
|
|
3526
|
+
};
|
|
3527
|
+
|
|
3528
|
+
const onClick = (event) => {
|
|
3529
|
+
const el = event.target;
|
|
3530
|
+
// A click on the tool itself: we let the event go down into the shadow
|
|
3531
|
+
// root, where our own buttons are waiting for it.
|
|
3532
|
+
if (inTool(el)) return;
|
|
3533
|
+
// Everything else is captured: in annotation mode one points, one does
|
|
3534
|
+
// not navigate. That is what keeps a click on a link from carrying the
|
|
3535
|
+
// person away at the moment they meant to comment on it.
|
|
3536
|
+
event.preventDefault();
|
|
3537
|
+
event.stopPropagation();
|
|
3538
|
+
if (event.type !== 'click') return;
|
|
3539
|
+
|
|
3540
|
+
/* THE POP/FORM DECISION IS THE HEAD'S. In 'full' the head is this same
|
|
3541
|
+
scope, so the two rules below run right here. In 'hands' the window and
|
|
3542
|
+
the form are in the host panel, which this sealed document cannot see; so
|
|
3543
|
+
the hands do not decide -- they report the pick, and the head closes an
|
|
3544
|
+
open window, keeps a half-written form, or opens a new one (FRAME-DESIGN,
|
|
3545
|
+
hard problem 1). */
|
|
3546
|
+
if (ROLE !== 'hands') {
|
|
3547
|
+
/* A CLICK OUTSIDE THE WINDOW CLOSES IT, rather than opening a form on
|
|
3548
|
+
whatever was clicked. Same reason as the frozen aim, and the same
|
|
3549
|
+
rule Escape follows: the window is the thing on top, so a click not
|
|
3550
|
+
in it dismisses it -- one gesture, and the page is not annotated by
|
|
3551
|
+
the gesture that puts the remark away. The next click aims and opens
|
|
3552
|
+
a form as usual: nothing is trapped. */
|
|
3553
|
+
if (pop) {
|
|
3554
|
+
/* The click says where the pointer is, which the frozen aim does
|
|
3555
|
+
not know: taking it here means the outline comes back UNDER THE
|
|
3556
|
+
HAND rather than on the element it was left on three scrolls
|
|
3557
|
+
ago. */
|
|
3558
|
+
if (el && el.nodeType === 1 && el !== document.body
|
|
3559
|
+
&& el !== document.documentElement) hovered = pickable(el) ? el : null;
|
|
3560
|
+
closePop();
|
|
3561
|
+
return;
|
|
3562
|
+
}
|
|
3563
|
+
/* AND A CLICK ELSEWHERE DOES NOT THROW A REMARK AWAY. openForm()
|
|
3564
|
+
rebuilds the form from nothing, so aiming at another element while
|
|
3565
|
+
something was written DISCARDED it -- silently, on a click the reader
|
|
3566
|
+
may not have meant. Nothing typed: aiming again costs nothing.
|
|
3567
|
+
Something typed: the form stays. Escape and Cancel are the two ways
|
|
3568
|
+
out, and both are on screen. */
|
|
3569
|
+
if (ui.form.classList.contains('ap-open')) {
|
|
3570
|
+
const written = ui.form.querySelector('.ap-area');
|
|
3571
|
+
if (written && written.value.trim() !== '') return;
|
|
3572
|
+
}
|
|
3573
|
+
}
|
|
3574
|
+
if (!el || el.nodeType !== 1) return;
|
|
3575
|
+
if (el === document.body || el === document.documentElement) return;
|
|
3576
|
+
/* OUTSIDE THE ZONE, NOTHING IS CREATED, and a form already open stays as
|
|
3577
|
+
it is: it is about an element inside. The click was still captured
|
|
3578
|
+
above, so a link out there does not carry the reader away either. */
|
|
3579
|
+
if (!pickable(el)) {
|
|
3580
|
+
const nowhere = pickVerdict(judgeZone(), el) === 'nowhere' || zoneMissing();
|
|
3581
|
+
sayOutsideZone(event, nowhere ? 'zone.none' : 'zone.outside');
|
|
3582
|
+
return;
|
|
3583
|
+
}
|
|
3584
|
+
hideZoneNotice();
|
|
3585
|
+
if (ROLE === 'hands') {
|
|
3586
|
+
/* The element lives in this sealed document; the head cannot reach it,
|
|
3587
|
+
so the hands send its anchor -- the very fields openForm would have
|
|
3588
|
+
computed on save (cssPath/fingerprintOf/excerptOf). The hands also
|
|
3589
|
+
keep the local aim on it, for the context the reader needs while the
|
|
3590
|
+
form is in the other document. */
|
|
3591
|
+
hovered = el;
|
|
3592
|
+
showHighlight(el);
|
|
3593
|
+
bridgeSend('picked', {
|
|
3594
|
+
selector: cssPath(el),
|
|
3595
|
+
fingerprint: fingerprintOf(el),
|
|
3596
|
+
excerpt: excerptOf(el)
|
|
3597
|
+
});
|
|
3598
|
+
return;
|
|
3599
|
+
}
|
|
3600
|
+
openForm(el);
|
|
3601
|
+
};
|
|
3602
|
+
|
|
3603
|
+
const onKey = (event) => {
|
|
3604
|
+
if (event.key !== 'Escape') return;
|
|
3605
|
+
/* In 'hands' the window, the form and the mode are all the head's: Escape
|
|
3606
|
+
pressed over the sealed page is relayed, and the head runs exactly the
|
|
3607
|
+
cascade below in its own scope. */
|
|
3608
|
+
if (ROLE === 'hands') {
|
|
3609
|
+
bridgeSend('escape');
|
|
3610
|
+
return;
|
|
3611
|
+
}
|
|
3612
|
+
/* The window first: it is the thing on top, and Escape closes what is on
|
|
3613
|
+
top. Leaving annotation mode from under an open window would take the
|
|
3614
|
+
page away and leave the window floating over it. */
|
|
3615
|
+
if (pop) {
|
|
3616
|
+
closePop();
|
|
3617
|
+
return;
|
|
3618
|
+
}
|
|
3619
|
+
if (ui.form.classList.contains('ap-open')) {
|
|
3620
|
+
closeForm();
|
|
3621
|
+
return;
|
|
3622
|
+
}
|
|
3623
|
+
leaveMode();
|
|
3624
|
+
};
|
|
3625
|
+
|
|
3626
|
+
/* THE HANDS ENTER THE MODE: the listeners, the observer and the first draw --
|
|
3627
|
+
the half of the old enterMode that touches the page. In 'full' the head's
|
|
3628
|
+
enterMode calls this straight after raising the panel; in 'hands' the
|
|
3629
|
+
`pick:on` handler calls it when the head says so. It never touches the button
|
|
3630
|
+
or the panel, and it never asks the server: those are the head's.
|
|
3631
|
+
|
|
3632
|
+
THE PAGE REDRAWS ITSELF, AND THE BADGES MUST NOT DIE OF IT. A click on the
|
|
3633
|
+
site's own button can replace a whole block: the node we remembered is then
|
|
3634
|
+
detached, it measures 0x0, and the badge simply stops being drawn. The
|
|
3635
|
+
observer's callback raises a flag AND NOTHING ELSE; all the work happens in
|
|
3636
|
+
the animation frame of refreshPositions, at most once per frame, so a page
|
|
3637
|
+
that mutates in a loop does not pay a full re-anchoring per mutation record.
|
|
3638
|
+
It is observed on document.body, childList and subtree, and never crosses
|
|
3639
|
+
into the shadow root -- the tool cannot see, or answer, its own drawing. */
|
|
3640
|
+
const handsEnter = () => {
|
|
3641
|
+
mode = true;
|
|
3642
|
+
document.addEventListener('pointerover', onHover, true);
|
|
3643
|
+
document.addEventListener('pointerdown', onClick, true);
|
|
3644
|
+
document.addEventListener('click', onClick, true);
|
|
3645
|
+
document.addEventListener('auxclick', onClick, true);
|
|
3646
|
+
document.addEventListener('keydown', onKey, true);
|
|
3647
|
+
window.addEventListener('scroll', refreshPositions, true);
|
|
3648
|
+
window.addEventListener('resize', refreshPositions);
|
|
3649
|
+
// A carousel, a dropdown menu, an image loaded late move the elements
|
|
3650
|
+
// without emitting either scroll or resize.
|
|
3651
|
+
timer = window.setInterval(refreshPositions, 500);
|
|
3652
|
+
|
|
3653
|
+
if (typeof MutationObserver === 'function') {
|
|
3654
|
+
observer = new MutationObserver(() => {
|
|
3655
|
+
domDirty = true;
|
|
3656
|
+
});
|
|
3657
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
3658
|
+
}
|
|
3659
|
+
domDirty = false;
|
|
3660
|
+
zoneMissing();
|
|
3661
|
+
|
|
3662
|
+
// The markers for what we ALREADY know, straight away; in 'full' the server
|
|
3663
|
+
// is asked next (the head's reload) and corrects anything new, and in
|
|
3664
|
+
// 'hands' the head sends the list over the bridge. Waiting for either to
|
|
3665
|
+
// show what is already on screen would suggest an empty page.
|
|
3666
|
+
drawMarkers();
|
|
3667
|
+
};
|
|
3668
|
+
|
|
3669
|
+
/* THE HANDS LEAVE THE MODE: the exact undoing of handsEnter, and nothing of the
|
|
3670
|
+
head's. */
|
|
3671
|
+
const handsLeave = () => {
|
|
3672
|
+
mode = false;
|
|
3673
|
+
hideHighlight();
|
|
3674
|
+
hovered = null;
|
|
3675
|
+
if (ui.markers) empty(ui.markers);
|
|
3676
|
+
if (ui.zones) empty(ui.zones);
|
|
3677
|
+
hideZoneNotice();
|
|
3678
|
+
|
|
3679
|
+
document.removeEventListener('pointerover', onHover, true);
|
|
3680
|
+
document.removeEventListener('pointerdown', onClick, true);
|
|
3681
|
+
document.removeEventListener('click', onClick, true);
|
|
3682
|
+
document.removeEventListener('auxclick', onClick, true);
|
|
3683
|
+
document.removeEventListener('keydown', onKey, true);
|
|
3684
|
+
window.removeEventListener('scroll', refreshPositions, true);
|
|
3685
|
+
window.removeEventListener('resize', refreshPositions);
|
|
3686
|
+
// Outside annotation mode the tool watches nothing: the site is the
|
|
3687
|
+
// site's again, and it pays nothing for us.
|
|
3688
|
+
if (observer) {
|
|
3689
|
+
observer.disconnect();
|
|
3690
|
+
observer = null;
|
|
3691
|
+
}
|
|
3692
|
+
domDirty = false;
|
|
3693
|
+
if (timer) {
|
|
3694
|
+
window.clearInterval(timer);
|
|
3695
|
+
timer = null;
|
|
3696
|
+
}
|
|
3697
|
+
};
|
|
3698
|
+
|
|
3699
|
+
/* ==== 60-ui.js ==== */
|
|
3700
|
+
|
|
3701
|
+
/* -- 14 ter. Entering and leaving the mode -------------------------------
|
|
3702
|
+
The mode is the HEAD's to open and close: the button and the panel are here,
|
|
3703
|
+
and so is the server (reload). The page work -- the listeners, the markers,
|
|
3704
|
+
the pointer -- is the HANDS' (handsEnter/handsLeave, 58-hands).
|
|
3705
|
+
|
|
3706
|
+
In 'full' this calls both halves, in the original order, so nothing it does
|
|
3707
|
+
can move a pixel or change a sequence. In 'head' it does the head's half and
|
|
3708
|
+
tells the hands over the bridge; the hands, booted apart in the iframe, run
|
|
3709
|
+
handsEnter from their `pick:on` handler. A 'hands'-only build never has a
|
|
3710
|
+
button, so it never calls this -- its mode is driven entirely by pick:on/off. */
|
|
3711
|
+
const pickPayload = () => ({ declared: ZONE_DECLARED, selector: ZONE_SELECTOR });
|
|
3712
|
+
|
|
3713
|
+
const enterMode = () => {
|
|
3714
|
+
if (ROLE !== 'hands') {
|
|
3715
|
+
mode = true;
|
|
3716
|
+
ui.button.setAttribute('aria-pressed', 'true');
|
|
3717
|
+
ui.buttonText.textContent = T('button.close');
|
|
3718
|
+
ui.panel.classList.add('ap-open');
|
|
3719
|
+
}
|
|
3720
|
+
if (ROLE === 'head') bridgeSend('pick:on', pickPayload());
|
|
3721
|
+
else handsEnter();
|
|
3722
|
+
if (ROLE !== 'hands') reload();
|
|
3723
|
+
};
|
|
3724
|
+
|
|
3725
|
+
const leaveMode = () => {
|
|
3726
|
+
if (ROLE !== 'hands') {
|
|
3727
|
+
mode = false;
|
|
3728
|
+
closePop();
|
|
3729
|
+
ui.button.setAttribute('aria-pressed', 'false');
|
|
3730
|
+
ui.buttonText.textContent = T('button.open');
|
|
3731
|
+
ui.panel.classList.remove('ap-open');
|
|
3732
|
+
closeForm();
|
|
3733
|
+
}
|
|
3734
|
+
if (ROLE === 'head') bridgeSend('pick:off');
|
|
3735
|
+
else handsLeave();
|
|
3736
|
+
};
|
|
3737
|
+
|
|
3738
|
+
const toggleMode = () => (mode ? leaveMode() : enterMode());
|
|
3739
|
+
|
|
3740
|
+
/* -- 14 quater. The head's side of the bridge (frame mode) ----------------
|
|
3741
|
+
Wired only in 'head' (startHeadBridge, from the boot). In 'full' and 'hands'
|
|
3742
|
+
none of this runs, and in 'hands' these names are never reached. */
|
|
3743
|
+
|
|
3744
|
+
/* The marker dataset the hands draw: the anchor of each note, and the state the
|
|
3745
|
+
head computed for it -- the hands do not know the site version noteState
|
|
3746
|
+
needs, so they never recompute it (FRAME-DESIGN, data model). */
|
|
3747
|
+
const markerItem = (note) => ({
|
|
3748
|
+
id: note.id,
|
|
3749
|
+
selector: note.selector,
|
|
3750
|
+
fingerprint: note.fingerprint,
|
|
3751
|
+
excerpt: note.excerpt,
|
|
3752
|
+
state: noteState(note)
|
|
3753
|
+
});
|
|
3754
|
+
|
|
3755
|
+
const sendMarkers = () => {
|
|
3756
|
+
const items = [];
|
|
3757
|
+
for (let i = 0; i < notes.length; i += 1) items.push(markerItem(notes[i]));
|
|
3758
|
+
bridgeSend('markers', { items: items });
|
|
3759
|
+
};
|
|
3760
|
+
|
|
3761
|
+
/* SHOW A NOTE'S ELEMENT ON THE PAGE. In 'full' the page is right here and
|
|
3762
|
+
showElement scrolls to it; in 'head' the page is in the iframe, so the hands
|
|
3763
|
+
are asked to scroll and flash it. The head cannot see the result across the
|
|
3764
|
+
boundary, so it answers 'scrolled' optimistically -- the orphan case, which
|
|
3765
|
+
is the one that must not promise a scroll, is already decided by the caller
|
|
3766
|
+
(showNote passes 'gone' for an orphan before ever asking). */
|
|
3767
|
+
const locate = (note) => {
|
|
3768
|
+
if (ROLE === 'head') {
|
|
3769
|
+
bridgeSend('show', { id: note.id });
|
|
3770
|
+
return 'scrolled';
|
|
3771
|
+
}
|
|
3772
|
+
return showElement(note);
|
|
3773
|
+
};
|
|
3774
|
+
|
|
3775
|
+
/* A pick came back from the hands. The head owns the decision the hands could
|
|
3776
|
+
not make (hard problem 1): a click dismisses an open window; a half-written
|
|
3777
|
+
form is kept; otherwise a new form opens on the sent anchor. */
|
|
3778
|
+
const headPicked = (data) => {
|
|
3779
|
+
if (pop) { closePop(); return; }
|
|
3780
|
+
if (ui.form.classList.contains('ap-open')) {
|
|
3781
|
+
const written = ui.form.querySelector('.ap-area');
|
|
3782
|
+
if (written && written.value.trim() !== '') return;
|
|
3783
|
+
}
|
|
3784
|
+
openForm(data || {});
|
|
3785
|
+
};
|
|
3786
|
+
|
|
3787
|
+
/* A marker was tapped in the iframe: the window for those notes opens here. */
|
|
3788
|
+
const headTapped = (data) => {
|
|
3789
|
+
const ids = (data && data.ids) || [];
|
|
3790
|
+
const group = [];
|
|
3791
|
+
for (let i = 0; i < notes.length; i += 1) {
|
|
3792
|
+
if (ids.indexOf(notes[i].id) !== -1) group.push(notes[i]);
|
|
3793
|
+
}
|
|
3794
|
+
if (group.length) showNotes(group, false, group[0].excerpt || T('list.untitled'), null);
|
|
3795
|
+
};
|
|
3796
|
+
|
|
3797
|
+
/* The hands re-anchored and say which notes they could not place: the panel's
|
|
3798
|
+
orphan section is the head's to show, from the ids they sent. */
|
|
3799
|
+
const headAnchored = (data) => {
|
|
3800
|
+
const ids = (data && data.orphanIds) || [];
|
|
3801
|
+
const next = [];
|
|
3802
|
+
for (let i = 0; i < notes.length; i += 1) {
|
|
3803
|
+
if (ids.indexOf(notes[i].id) !== -1) next.push(notes[i]);
|
|
3804
|
+
}
|
|
3805
|
+
orphans = next;
|
|
3806
|
+
drawPanel();
|
|
3807
|
+
};
|
|
3808
|
+
|
|
3809
|
+
/* Escape pressed over the sealed page: the head runs its own cascade. */
|
|
3810
|
+
const headEscape = () => {
|
|
3811
|
+
if (pop) { closePop(); return; }
|
|
3812
|
+
if (ui.form.classList.contains('ap-open')) { closeForm(); return; }
|
|
3813
|
+
leaveMode();
|
|
3814
|
+
};
|
|
3815
|
+
|
|
3816
|
+
/* Wires the head to the iframe's window. Called once from the boot. */
|
|
3817
|
+
const startHeadBridge = (frameWindow) => {
|
|
3818
|
+
/* No window to pair with. An <iframe> not yet in the document has a null
|
|
3819
|
+
contentWindow; starting the bridge against nothing would let it pair with
|
|
3820
|
+
the FIRST window that speaks -- the very de-pinning the source check
|
|
3821
|
+
exists to prevent. Say so and do not start: the head has no hands until
|
|
3822
|
+
there is a real frame window. (A non-<iframe> never reaches here: it is
|
|
3823
|
+
refused where the option is read, in 00-preamble.) */
|
|
3824
|
+
if (!frameWindow) {
|
|
3825
|
+
complain('the frame has no contentWindow (is the <iframe> in the '
|
|
3826
|
+
+ 'document?); the panel will not connect to it.');
|
|
3827
|
+
return;
|
|
3828
|
+
}
|
|
3829
|
+
bridgeConnect(frameWindow);
|
|
3830
|
+
onBridge('ready', () => {
|
|
3831
|
+
// The hands (re)appeared -- a reload of the iframe rebuilds them. If the
|
|
3832
|
+
// reader is already in annotation mode, catch the new hands up: turn
|
|
3833
|
+
// pointing on and hand over the current markers.
|
|
3834
|
+
if (mode) {
|
|
3835
|
+
bridgeSend('pick:on', pickPayload());
|
|
3836
|
+
sendMarkers();
|
|
3837
|
+
}
|
|
3838
|
+
});
|
|
3839
|
+
onBridge('picked', (d) => headPicked(d));
|
|
3840
|
+
onBridge('tapped', (d) => headTapped(d));
|
|
3841
|
+
onBridge('anchored', (d) => headAnchored(d));
|
|
3842
|
+
onBridge('escape', () => headEscape());
|
|
3843
|
+
bridgeStart(frameWindow);
|
|
3844
|
+
};
|
|
3845
|
+
|
|
3846
|
+
/* -- What the whole project holds ----------------------------------------
|
|
3847
|
+
IN THE FOOTER, WHICH IS WHERE THE PANEL ALREADY KEEPS ITS STANDING FACTS:
|
|
3848
|
+
who you are, and what to do about the key. Three counts for the site are the
|
|
3849
|
+
same kind of thing -- context, not content -- and under the header they sat
|
|
3850
|
+
between the panel's title and its instructions, which is the path a reader
|
|
3851
|
+
takes to the notes themselves.
|
|
3852
|
+
|
|
3853
|
+
THREE NUMBERS, AND ONLY IF THE SERVER SENT THEM. `totals` is null against a
|
|
3854
|
+
server that does not know the field, and the row is then not drawn at all:
|
|
3855
|
+
showing three zeros would make an old server look like an empty project, and
|
|
3856
|
+
a tool that confuses those two teaches a reviewer to distrust what it says.
|
|
3857
|
+
|
|
3858
|
+
Drawn by drawPanel, with the rest of the footer: the footer is emptied at
|
|
3859
|
+
every draw, so anything appended from elsewhere would land after the buttons
|
|
3860
|
+
or not at all. */
|
|
3861
|
+
|
|
3862
|
+
const statsRow = () => {
|
|
3863
|
+
if (totals === null) return null;
|
|
3864
|
+
const rows = create('div', 'ap-stats');
|
|
3865
|
+
|
|
3866
|
+
/* ONE, AND THEN THE PLURAL. "1 pages" beside a figure the tool is asking
|
|
3867
|
+
to be believed reads as carelessness. The singular label is looked up
|
|
3868
|
+
first and English is the fallback for a translation that has not written
|
|
3869
|
+
one, which is the rule everywhere else here. */
|
|
3870
|
+
const figure = (n, word) => {
|
|
3871
|
+
const box = create('span', 'ap-stat');
|
|
3872
|
+
box.appendChild(create('span', 'ap-stat-n', readableNumber(n)));
|
|
3873
|
+
box.appendChild(create('span', 'ap-stat-w', T(n === 1 ? word + '_one' : word)));
|
|
3874
|
+
return box;
|
|
3875
|
+
};
|
|
3876
|
+
|
|
3877
|
+
/* UP TO THREE ROWS OF ONE SHAPE: this site, the server holding it, every
|
|
3878
|
+
server there is. A label and at most three figures each, the same size
|
|
3879
|
+
in all three -- the last row is one more scope, not an advertisement.
|
|
3880
|
+
The first is always there; each of the others only where this server
|
|
3881
|
+
has it to give. */
|
|
3882
|
+
const block = (label, aside) => {
|
|
3883
|
+
const box = create('div', 'ap-stats-block');
|
|
3884
|
+
const head = create('span', 'ap-stat-label', T(label));
|
|
3885
|
+
if (aside) head.appendChild(create('span', 'ap-stat-aside', T(aside)));
|
|
3886
|
+
box.appendChild(head);
|
|
3887
|
+
const row = create('div', 'ap-panel-stats');
|
|
3888
|
+
box.appendChild(row);
|
|
3889
|
+
rows.appendChild(box);
|
|
3890
|
+
return { box: box, row: row };
|
|
3891
|
+
};
|
|
3892
|
+
|
|
3893
|
+
/* NOTES WRITTEN, AND WHAT AGE TOOK IS AMONG THEM. A server that removes
|
|
3894
|
+
old threads used to show what was left and, on a line of its own, what
|
|
3895
|
+
had gone: two figures to add up for one answer, and a count of notes
|
|
3896
|
+
that went DOWN on a site people were still using. What was written was
|
|
3897
|
+
written. "Written" is in the label so that "still open" beside it reads
|
|
3898
|
+
as a part of it and not as a second count of the same thing. */
|
|
3899
|
+
const gone = expired !== null ? expired : { notes: 0, pages: 0 };
|
|
3900
|
+
|
|
3901
|
+
const here = block('panel.stats_here_label');
|
|
3902
|
+
here.row.appendChild(figure(totals.notes + gone.notes, 'panel.stats_written'));
|
|
3903
|
+
here.row.appendChild(figure(totals.open, 'panel.stats_open'));
|
|
3904
|
+
here.row.appendChild(figure(totals.pages + gone.pages, 'panel.stats_pages'));
|
|
3905
|
+
|
|
3906
|
+
/* THE WHOLE SERVER, on the servers whose operator chose to publish it.
|
|
3907
|
+
Absent everywhere else -- see `publish_server_totals`, which is off until
|
|
3908
|
+
somebody writes it. Sites and notes: pages are a figure of the site,
|
|
3909
|
+
where the reader can see them. */
|
|
3910
|
+
if (serverWide !== null) {
|
|
3911
|
+
const all = block('panel.stats_server_label');
|
|
3912
|
+
all.row.appendChild(figure(serverWide.projects, 'panel.stats_sites'));
|
|
3913
|
+
all.row.appendChild(figure(serverWide.notes + serverWide.expiredNotes, 'panel.stats_written'));
|
|
3914
|
+
}
|
|
3915
|
+
|
|
3916
|
+
/* AND EVERY SERVER TOGETHER, where this one takes part in the statistics.
|
|
3917
|
+
SERVERS AND SITES BEFORE NOTES: a count of notes alone could be one
|
|
3918
|
+
person's, and what a reader wants to know is whether anybody else uses
|
|
3919
|
+
this. The figures are a day old, and the label says so. */
|
|
3920
|
+
if (world !== null) {
|
|
3921
|
+
const everywhere = block('panel.stats_world_label', 'panel.stats_daily');
|
|
3922
|
+
everywhere.box.classList.add('ap-stats-world');
|
|
3923
|
+
if (world.servers !== null) {
|
|
3924
|
+
everywhere.row.appendChild(figure(world.servers, 'panel.stats_servers'));
|
|
3925
|
+
}
|
|
3926
|
+
if (world.sites !== null) {
|
|
3927
|
+
everywhere.row.appendChild(figure(world.sites, 'panel.stats_sites'));
|
|
3928
|
+
}
|
|
3929
|
+
everywhere.row.appendChild(figure(world.notes, 'panel.stats_written'));
|
|
3930
|
+
}
|
|
3931
|
+
|
|
3932
|
+
return rows;
|
|
3292
3933
|
};
|
|
3293
3934
|
|
|
3294
|
-
/*
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
const ZONES_DRAWN = 64;
|
|
3935
|
+
/* -- The side the panel sits on ------------------------------------------
|
|
3936
|
+
The class carries ONE name, deliberately: ".ap-left" weighs exactly as
|
|
3937
|
+
much as ".ap-panel", so the narrow block further down the stylesheet --
|
|
3938
|
+
where the panel is a bottom band and the side means nothing -- wins over
|
|
3939
|
+
it by being written later. */
|
|
3300
3940
|
|
|
3301
|
-
const
|
|
3302
|
-
|
|
3303
|
-
if (
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3941
|
+
const applySide = () => {
|
|
3942
|
+
if (!ui) return;
|
|
3943
|
+
if (side === 'left') ui.panel.classList.add('ap-left');
|
|
3944
|
+
else ui.panel.classList.remove('ap-left');
|
|
3945
|
+
/* AND THE FLOATING BUTTON GOES WITH IT. It is not inside the panel, so
|
|
3946
|
+
the side is carried by the layer, which is the ancestor they share.
|
|
3947
|
+
Moving only the panel would put the control that opens it on the
|
|
3948
|
+
opposite edge from the thing it opens. */
|
|
3949
|
+
if (side === 'left') ui.layer.classList.add('ap-left-side');
|
|
3950
|
+
else ui.layer.classList.remove('ap-left-side');
|
|
3951
|
+
/* Docked, there is no toggle to label: the panel fills the container and
|
|
3952
|
+
has no side to move to (57-shell builds none). The side classes above
|
|
3953
|
+
are harmless there -- .ap-docked .ap-panel overrides them -- so the
|
|
3954
|
+
floating path is left exactly as it was. */
|
|
3955
|
+
if (ui.sideToggle) {
|
|
3956
|
+
ui.sideToggle.textContent = side === 'left'
|
|
3957
|
+
? T('panel.move_right') : T('panel.move_left');
|
|
3315
3958
|
}
|
|
3316
3959
|
};
|
|
3317
3960
|
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
const x = typeof event.clientX === 'number' ? event.clientX : window.innerWidth / 2;
|
|
3327
|
-
const y = typeof event.clientY === 'number' ? event.clientY : window.innerHeight / 2;
|
|
3328
|
-
notice.style.left = Math.max(8, Math.min(x + 12, window.innerWidth - notice.offsetWidth - 8)) + 'px';
|
|
3329
|
-
notice.style.top = Math.max(8, Math.min(y + 16, window.innerHeight - notice.offsetHeight - 8)) + 'px';
|
|
3330
|
-
if (zoneNoticeTimer) window.clearTimeout(zoneNoticeTimer);
|
|
3331
|
-
zoneNoticeTimer = window.setTimeout(hideZoneNotice, 2600);
|
|
3961
|
+
const moveSide = () => {
|
|
3962
|
+
writeSide(side === 'left' ? 'right' : 'left');
|
|
3963
|
+
applySide();
|
|
3964
|
+
/* The form is placed against the band the panel occupies, so the band
|
|
3965
|
+
having moved, it has to be measured again -- otherwise the form stays
|
|
3966
|
+
clamped away from an edge that is now free, and towards the one that
|
|
3967
|
+
is not. */
|
|
3968
|
+
if (target && document.contains(target)) positionForm(target);
|
|
3332
3969
|
};
|
|
3333
3970
|
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3971
|
+
/* -- 14. Markers --------------------------------------------------------- */
|
|
3972
|
+
|
|
3973
|
+
/* WHAT STATE A REMARK IS IN, IN ONE PLACE. The same three lines were written
|
|
3974
|
+
in the row, in the card and, the day the markers gained a colour, they would
|
|
3975
|
+
have been written a third time. The middle state is the one that must not be
|
|
3976
|
+
folded into the others: resolved but not deployed is a defect still on the
|
|
3977
|
+
reader's screen, and anything drawing it as done lies at a glance. */
|
|
3978
|
+
const noteState = (note) => {
|
|
3979
|
+
if (!note.resolved_at) return 'open';
|
|
3980
|
+
return alreadyDeployed(note.resolved_version) ? 'done' : 'pending';
|
|
3981
|
+
};
|
|
3982
|
+
|
|
3983
|
+
/* AND WHAT STATE A GROUP OF THEM IS IN: the most urgent one present. A badge
|
|
3984
|
+
that averaged its remarks would go quiet on an element still carrying an
|
|
3985
|
+
open one. */
|
|
3986
|
+
const groupState = (notes) => {
|
|
3987
|
+
let seen = 'done';
|
|
3988
|
+
for (let i = 0; i < notes.length; i += 1) {
|
|
3989
|
+
const one = noteState(notes[i]);
|
|
3990
|
+
if (one === 'open') return 'open';
|
|
3991
|
+
if (one === 'pending') seen = 'pending';
|
|
3992
|
+
}
|
|
3993
|
+
return seen;
|
|
3338
3994
|
};
|
|
3339
3995
|
|
|
3340
3996
|
/* -- 15. The panel ------------------------------------------------------- */
|
|
@@ -3455,7 +4111,7 @@
|
|
|
3455
4111
|
const showNote = (note, orphan) => {
|
|
3456
4112
|
/* THE PAGE IS ASKED TO MOVE FIRST, so that what the window says about it is
|
|
3457
4113
|
what actually happened rather than a guess made before trying. */
|
|
3458
|
-
const went = orphan ? 'gone' :
|
|
4114
|
+
const went = orphan ? 'gone' : locate(note);
|
|
3459
4115
|
showNotes([note], orphan, note.title || note.excerpt || T('list.untitled'),
|
|
3460
4116
|
went === 'scrolled' ? null
|
|
3461
4117
|
: T(went === 'hidden' ? 'list.not_shown' : 'list.not_here'));
|
|
@@ -3517,7 +4173,7 @@
|
|
|
3517
4173
|
if (!orphan) {
|
|
3518
4174
|
const show = create('button', 'ap-link', T('note.show'));
|
|
3519
4175
|
show.type = 'button';
|
|
3520
|
-
show.addEventListener('click', () =>
|
|
4176
|
+
show.addEventListener('click', () => locate(note));
|
|
3521
4177
|
actions.appendChild(show);
|
|
3522
4178
|
}
|
|
3523
4179
|
/* Mark resolved, and take that mark back. Without this button, half the
|
|
@@ -4112,6 +4768,13 @@
|
|
|
4112
4768
|
const isPlain = (MODE === 'plain');
|
|
4113
4769
|
const isPublic = PUBLIC_KEY;
|
|
4114
4770
|
const which = isPlain ? 'plain' : (isPublic ? 'public' : 'secure');
|
|
4771
|
+
/* THE PUBLIC WARNING, AND ONLY IT, CAN BE SILENCED. On a site that gates
|
|
4772
|
+
the page behind its own login, "the key is in this page" is not the alarm
|
|
4773
|
+
it is on an open page, and the host says so with publicnotice="off"
|
|
4774
|
+
(PUBLIC_NOTICE, 00-preamble). Off by default, so without it the badge is
|
|
4775
|
+
drawn exactly as before; 'plain' and 'secure' are never touched -- they
|
|
4776
|
+
say which mode this is, which nothing here lets a host hide. */
|
|
4777
|
+
if (which === 'public' && !PUBLIC_NOTICE) return null;
|
|
4115
4778
|
const block = create('div', 'ap-mode ap-mode-' + which);
|
|
4116
4779
|
|
|
4117
4780
|
/* The id is drawn, because the panel is redrawn: two badges alive at the
|
|
@@ -4185,7 +4848,10 @@
|
|
|
4185
4848
|
empty(ui.footer);
|
|
4186
4849
|
|
|
4187
4850
|
|
|
4188
|
-
|
|
4851
|
+
// null when the public warning is silenced (publicnotice="off"); every
|
|
4852
|
+
// other mode draws a badge, so this is the only time there is none.
|
|
4853
|
+
const modeEl = modeBadge();
|
|
4854
|
+
if (modeEl) ui.body.appendChild(modeEl);
|
|
4189
4855
|
|
|
4190
4856
|
/* A NEWER CLIENT EXISTS, AND WE ARE NOT GOING TO FETCH IT. This copy is
|
|
4191
4857
|
served by the site itself -- somebody took the file off a CDN on
|
|
@@ -4442,24 +5108,6 @@
|
|
|
4442
5108
|
*
|
|
4443
5109
|
* @returns {'scrolled'|'hidden'|'gone'}
|
|
4444
5110
|
*/
|
|
4445
|
-
const showElement = (note) => {
|
|
4446
|
-
let el = null;
|
|
4447
|
-
for (let i = 0; i < anchored.length; i += 1) {
|
|
4448
|
-
if (anchored[i].notes.indexOf(note) !== -1) el = anchored[i].element;
|
|
4449
|
-
}
|
|
4450
|
-
if (!el || !document.contains(el)) return 'gone';
|
|
4451
|
-
const r = el.getBoundingClientRect();
|
|
4452
|
-
if (r.width === 0 && r.height === 0) return 'hidden';
|
|
4453
|
-
// scrollIntoView moves the viewpoint, never the document: no node, no
|
|
4454
|
-
// style of the site is touched.
|
|
4455
|
-
el.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
|
4456
|
-
window.setTimeout(() => {
|
|
4457
|
-
showHighlight(el);
|
|
4458
|
-
window.setTimeout(hideHighlight, 1400);
|
|
4459
|
-
}, 350);
|
|
4460
|
-
return 'scrolled';
|
|
4461
|
-
};
|
|
4462
|
-
|
|
4463
5111
|
/* -- 16. The form for a new note ------------------------------------------ */
|
|
4464
5112
|
|
|
4465
5113
|
const positionForm = (el) => {
|
|
@@ -4533,12 +5181,27 @@
|
|
|
4533
5181
|
* carrying it over would make it disappear under the fingers of whoever is
|
|
4534
5182
|
* writing: that is the same wrong as losing a note.
|
|
4535
5183
|
*/
|
|
4536
|
-
const openForm = (
|
|
5184
|
+
const openForm = (source, existingText) => {
|
|
5185
|
+
/* The element when it is in THIS document (full mode), otherwise null: in
|
|
5186
|
+
head/frame mode the element is in the sealed iframe and the hands have
|
|
5187
|
+
already sent its anchor. */
|
|
5188
|
+
const el = source && source.nodeType === 1 ? source : null;
|
|
5189
|
+
/* THE ANCHOR, COMPUTED ONCE. From the element here, or taken from what the
|
|
5190
|
+
hands sent -- the very three fields cssPath/fingerprintOf/excerptOf would
|
|
5191
|
+
have produced over there. The save reads it, so both modes write the same
|
|
5192
|
+
note. */
|
|
5193
|
+
const anchor = el
|
|
5194
|
+
? { selector: cssPath(el), fingerprint: fingerprintOf(el), excerpt: excerptOf(el) }
|
|
5195
|
+
: {
|
|
5196
|
+
selector: (source && source.selector) || '',
|
|
5197
|
+
fingerprint: (source && source.fingerprint) || '',
|
|
5198
|
+
excerpt: (source && source.excerpt) || ''
|
|
5199
|
+
};
|
|
4537
5200
|
target = el;
|
|
4538
5201
|
const form = ui.form;
|
|
4539
5202
|
empty(form);
|
|
4540
5203
|
|
|
4541
|
-
const excerpt =
|
|
5204
|
+
const excerpt = anchor.excerpt;
|
|
4542
5205
|
form.appendChild(create('div', 'ap-form-title', T('form.title')));
|
|
4543
5206
|
form.appendChild(create('div', 'ap-form-target',
|
|
4544
5207
|
excerpt ? T('form.about', { excerpt: excerpt }) : T('form.about_no_text')));
|
|
@@ -4564,7 +5227,7 @@
|
|
|
4564
5227
|
// changing the name does not cost what has been written.
|
|
4565
5228
|
const pending = area.value;
|
|
4566
5229
|
writeAuthor('');
|
|
4567
|
-
openForm(
|
|
5230
|
+
openForm(source, pending);
|
|
4568
5231
|
});
|
|
4569
5232
|
reminder.appendChild(change);
|
|
4570
5233
|
}
|
|
@@ -4625,8 +5288,8 @@
|
|
|
4625
5288
|
const before = notes.map((n) => n.id);
|
|
4626
5289
|
noteBody({
|
|
4627
5290
|
page: pagePath(),
|
|
4628
|
-
selector:
|
|
4629
|
-
fingerprint:
|
|
5291
|
+
selector: anchor.selector,
|
|
5292
|
+
fingerprint: anchor.fingerprint,
|
|
4630
5293
|
excerpt: excerpt,
|
|
4631
5294
|
author: writer,
|
|
4632
5295
|
text: text,
|
|
@@ -4664,200 +5327,19 @@
|
|
|
4664
5327
|
});
|
|
4665
5328
|
});
|
|
4666
5329
|
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
5330
|
+
/* WHERE THE FORM SHOWS. With an element in this document it floats over it,
|
|
5331
|
+
and on a narrow screen the panel steps aside so the typing has the room --
|
|
5332
|
+
exactly as it always has. In head/frame mode there is no element here:
|
|
5333
|
+
the form shows inside the panel (decision A), so the panel stays and
|
|
5334
|
+
nothing is positioned over the page. The order is kept -- 'ap-open' is
|
|
5335
|
+
added before positionForm measures the form -- so full mode is untouched. */
|
|
5336
|
+
if (el && narrowScreen()) ui.panel.classList.remove('ap-open');
|
|
5337
|
+
if (!el) form.classList.add('ap-form-in-panel');
|
|
4671
5338
|
form.classList.add('ap-open');
|
|
4672
|
-
positionForm(el);
|
|
5339
|
+
if (el) positionForm(el);
|
|
4673
5340
|
window.setTimeout(() => (name ? name.field : area).focus(), 0);
|
|
4674
5341
|
};
|
|
4675
5342
|
|
|
4676
|
-
/* -- 17. Annotation mode ------------------------------------------------- */
|
|
4677
|
-
|
|
4678
|
-
/* NOTHING IS AIMED AT WHILE A WINDOW IS OPEN. Reading a remark with the
|
|
4679
|
-
pointer resting anywhere over the page meant the outline kept jumping from
|
|
4680
|
-
paragraph to paragraph behind the window, and the label with it -- the tool
|
|
4681
|
-
proposing the next thing to annotate to somebody who is busy reading the
|
|
4682
|
-
last one. Reported as exactly that: it is distracting.
|
|
4683
|
-
|
|
4684
|
-
The aim is FROZEN, not merely hidden: `hovered` is left where it was, so
|
|
4685
|
-
closing the window puts the reader back on the element they had, rather than
|
|
4686
|
-
on whatever happens to be under a pointer that has not moved. */
|
|
4687
|
-
const onHover = (event) => {
|
|
4688
|
-
if (pop) return;
|
|
4689
|
-
/* AND NOT WHILE A REMARK IS BEING WRITTEN, for the same reason and on the
|
|
4690
|
-
same report: the outline and its label kept moving from paragraph to
|
|
4691
|
-
paragraph behind the form, so the tool was proposing the next thing to
|
|
4692
|
-
annotate to somebody in the middle of annotating this one. The element
|
|
4693
|
-
being written about stays outlined until the form closes -- which is
|
|
4694
|
-
what a reader looking away from their own sentence needs to find. */
|
|
4695
|
-
if (ui.form.classList.contains('ap-open')) return;
|
|
4696
|
-
const el = event.target;
|
|
4697
|
-
if (!el || el.nodeType !== 1 || inTool(el)) return;
|
|
4698
|
-
if (el === document.body || el === document.documentElement) return;
|
|
4699
|
-
/* Outside the zone the aim goes out: an outline there offers a remark
|
|
4700
|
-
the click is going to refuse. */
|
|
4701
|
-
if (!pickable(el)) {
|
|
4702
|
-
hovered = null;
|
|
4703
|
-
hideHighlight();
|
|
4704
|
-
return;
|
|
4705
|
-
}
|
|
4706
|
-
hovered = el;
|
|
4707
|
-
showHighlight(el);
|
|
4708
|
-
};
|
|
4709
|
-
|
|
4710
|
-
const onClick = (event) => {
|
|
4711
|
-
const el = event.target;
|
|
4712
|
-
// A click on the tool itself: we let the event go down into the shadow
|
|
4713
|
-
// root, where our own buttons are waiting for it.
|
|
4714
|
-
if (inTool(el)) return;
|
|
4715
|
-
// Everything else is captured: in annotation mode one points, one does
|
|
4716
|
-
// not navigate. That is what keeps a click on a link from carrying the
|
|
4717
|
-
// person away at the moment they meant to comment on it.
|
|
4718
|
-
event.preventDefault();
|
|
4719
|
-
event.stopPropagation();
|
|
4720
|
-
if (event.type !== 'click') return;
|
|
4721
|
-
/* AND A CLICK OUTSIDE THE WINDOW CLOSES IT, rather than opening a form on
|
|
4722
|
-
whatever was clicked. Same reason as the frozen aim, and the same rule
|
|
4723
|
-
Escape follows: the window is the thing on top, so a click that is not
|
|
4724
|
-
in it dismisses it -- one gesture, and the page is not annotated by the
|
|
4725
|
-
gesture that puts the remark away. The next click aims and opens a form
|
|
4726
|
-
as usual: nothing is trapped. */
|
|
4727
|
-
if (pop) {
|
|
4728
|
-
/* The click says where the pointer is, which is the one thing the
|
|
4729
|
-
frozen aim does not know: taking it here means the outline comes
|
|
4730
|
-
back UNDER THE HAND rather than on the element it was left on three
|
|
4731
|
-
scrolls ago. */
|
|
4732
|
-
if (el && el.nodeType === 1 && el !== document.body
|
|
4733
|
-
&& el !== document.documentElement) hovered = pickable(el) ? el : null;
|
|
4734
|
-
closePop();
|
|
4735
|
-
return;
|
|
4736
|
-
}
|
|
4737
|
-
/* AND A CLICK ELSEWHERE DOES NOT THROW A REMARK AWAY. openForm() rebuilds
|
|
4738
|
-
the form from nothing, so aiming at another element while something was
|
|
4739
|
-
written DISCARDED it -- silently, with no confirmation, on a click the
|
|
4740
|
-
reader may not have meant. Nothing typed: aiming again costs nothing and
|
|
4741
|
-
still works, which is what one does when the first click missed by one
|
|
4742
|
-
block. Something typed: the form stays where it is. Escape and Cancel
|
|
4743
|
-
are the two ways out, and both are on screen. */
|
|
4744
|
-
if (ui.form.classList.contains('ap-open')) {
|
|
4745
|
-
const written = ui.form.querySelector('.ap-area');
|
|
4746
|
-
if (written && written.value.trim() !== '') return;
|
|
4747
|
-
}
|
|
4748
|
-
if (!el || el.nodeType !== 1) return;
|
|
4749
|
-
if (el === document.body || el === document.documentElement) return;
|
|
4750
|
-
/* OUTSIDE THE ZONE, NOTHING IS CREATED, and a form already open stays as
|
|
4751
|
-
it is: it is about an element inside. The click was still captured
|
|
4752
|
-
above, so a link out there does not carry the reader away either. */
|
|
4753
|
-
if (!pickable(el)) {
|
|
4754
|
-
const nowhere = pickVerdict(judgeZone(), el) === 'nowhere' || zoneMissing();
|
|
4755
|
-
sayOutsideZone(event, nowhere ? 'zone.none' : 'zone.outside');
|
|
4756
|
-
return;
|
|
4757
|
-
}
|
|
4758
|
-
hideZoneNotice();
|
|
4759
|
-
openForm(el);
|
|
4760
|
-
};
|
|
4761
|
-
|
|
4762
|
-
const onKey = (event) => {
|
|
4763
|
-
if (event.key !== 'Escape') return;
|
|
4764
|
-
/* The window first: it is the thing on top, and Escape closes what is on
|
|
4765
|
-
top. Leaving annotation mode from under an open window would take the
|
|
4766
|
-
page away and leave the window floating over it. */
|
|
4767
|
-
if (pop) {
|
|
4768
|
-
closePop();
|
|
4769
|
-
return;
|
|
4770
|
-
}
|
|
4771
|
-
if (ui.form.classList.contains('ap-open')) {
|
|
4772
|
-
closeForm();
|
|
4773
|
-
return;
|
|
4774
|
-
}
|
|
4775
|
-
leaveMode();
|
|
4776
|
-
};
|
|
4777
|
-
|
|
4778
|
-
const enterMode = () => {
|
|
4779
|
-
mode = true;
|
|
4780
|
-
ui.button.setAttribute('aria-pressed', 'true');
|
|
4781
|
-
ui.buttonText.textContent = T('button.close');
|
|
4782
|
-
ui.panel.classList.add('ap-open');
|
|
4783
|
-
|
|
4784
|
-
document.addEventListener('pointerover', onHover, true);
|
|
4785
|
-
document.addEventListener('pointerdown', onClick, true);
|
|
4786
|
-
document.addEventListener('click', onClick, true);
|
|
4787
|
-
document.addEventListener('auxclick', onClick, true);
|
|
4788
|
-
document.addEventListener('keydown', onKey, true);
|
|
4789
|
-
window.addEventListener('scroll', refreshPositions, true);
|
|
4790
|
-
window.addEventListener('resize', refreshPositions);
|
|
4791
|
-
// A carousel, a dropdown menu, an image loaded late move the elements
|
|
4792
|
-
// without emitting either scroll or resize.
|
|
4793
|
-
timer = window.setInterval(refreshPositions, 500);
|
|
4794
|
-
|
|
4795
|
-
/* THE PAGE REDRAWS ITSELF, AND THE BADGES MUST NOT DIE OF IT. A click on
|
|
4796
|
-
the site's own button can replace a whole block: the node we remembered
|
|
4797
|
-
is then detached, it measures 0x0, and the badge simply stops being
|
|
4798
|
-
drawn.
|
|
4799
|
-
|
|
4800
|
-
The callback raises a flag AND NOTHING ELSE. All the work -- redoing
|
|
4801
|
-
the anchoring, deciding whether the panel changed -- happens in the
|
|
4802
|
-
animation frame of refreshPositions, at most once per frame. A page
|
|
4803
|
-
that mutates in a loop would otherwise pay for a full re-anchoring on
|
|
4804
|
-
every mutation record, which is how an annotation layer turns a lively
|
|
4805
|
-
page into a slow one.
|
|
4806
|
-
|
|
4807
|
-
Observed on document.body, childList and subtree: an element swapped
|
|
4808
|
-
anywhere is what breaks us. It never crosses into the shadow root, so
|
|
4809
|
-
the tool cannot see -- or answer -- its own drawing. */
|
|
4810
|
-
if (typeof MutationObserver === 'function') {
|
|
4811
|
-
observer = new MutationObserver(() => {
|
|
4812
|
-
domDirty = true;
|
|
4813
|
-
});
|
|
4814
|
-
observer.observe(document.body, { childList: true, subtree: true });
|
|
4815
|
-
}
|
|
4816
|
-
domDirty = false;
|
|
4817
|
-
zoneMissing();
|
|
4818
|
-
|
|
4819
|
-
// The markers for what we ALREADY know, straight away; the server is
|
|
4820
|
-
// asked next and will correct if there is anything new. Waiting for the
|
|
4821
|
-
// network to show what is already on screen would suggest an empty page.
|
|
4822
|
-
drawMarkers();
|
|
4823
|
-
reload();
|
|
4824
|
-
};
|
|
4825
|
-
|
|
4826
|
-
const leaveMode = () => {
|
|
4827
|
-
mode = false;
|
|
4828
|
-
closePop();
|
|
4829
|
-
ui.button.setAttribute('aria-pressed', 'false');
|
|
4830
|
-
ui.buttonText.textContent = T('button.open');
|
|
4831
|
-
ui.panel.classList.remove('ap-open');
|
|
4832
|
-
closeForm();
|
|
4833
|
-
hideHighlight();
|
|
4834
|
-
hovered = null;
|
|
4835
|
-
empty(ui.markers);
|
|
4836
|
-
empty(ui.zones);
|
|
4837
|
-
hideZoneNotice();
|
|
4838
|
-
|
|
4839
|
-
document.removeEventListener('pointerover', onHover, true);
|
|
4840
|
-
document.removeEventListener('pointerdown', onClick, true);
|
|
4841
|
-
document.removeEventListener('click', onClick, true);
|
|
4842
|
-
document.removeEventListener('auxclick', onClick, true);
|
|
4843
|
-
document.removeEventListener('keydown', onKey, true);
|
|
4844
|
-
window.removeEventListener('scroll', refreshPositions, true);
|
|
4845
|
-
window.removeEventListener('resize', refreshPositions);
|
|
4846
|
-
// Outside annotation mode the tool watches nothing: the site is the
|
|
4847
|
-
// site's again, and it pays nothing for us.
|
|
4848
|
-
if (observer) {
|
|
4849
|
-
observer.disconnect();
|
|
4850
|
-
observer = null;
|
|
4851
|
-
}
|
|
4852
|
-
domDirty = false;
|
|
4853
|
-
if (timer) {
|
|
4854
|
-
window.clearInterval(timer);
|
|
4855
|
-
timer = null;
|
|
4856
|
-
}
|
|
4857
|
-
};
|
|
4858
|
-
|
|
4859
|
-
const toggleMode = () => (mode ? leaveMode() : enterMode());
|
|
4860
|
-
|
|
4861
5343
|
/* ==== 70-setup.js ==== */
|
|
4862
5344
|
|
|
4863
5345
|
/* -- 18. Setup, and the key one pastes ----------------------------------
|
|
@@ -5873,6 +6355,15 @@
|
|
|
5873
6355
|
|
|
5874
6356
|
const redraw = () => {
|
|
5875
6357
|
if (!ui) return;
|
|
6358
|
+
/* In head/frame mode the anchoring and the markers belong to the hands, in
|
|
6359
|
+
the iframe: the head sends them the dataset and draws only its panel. The
|
|
6360
|
+
hands' `anchored` reply then fills the orphan section (headAnchored). In
|
|
6361
|
+
'full' the head is also the hands, and does all three right here. */
|
|
6362
|
+
if (ROLE === 'head') {
|
|
6363
|
+
sendMarkers();
|
|
6364
|
+
drawPanel();
|
|
6365
|
+
return;
|
|
6366
|
+
}
|
|
5876
6367
|
anchor();
|
|
5877
6368
|
drawPanel();
|
|
5878
6369
|
drawMarkers();
|
|
@@ -6133,6 +6624,27 @@
|
|
|
6133
6624
|
if (staleBoot(run, index)) return null;
|
|
6134
6625
|
clearLayer();
|
|
6135
6626
|
buildUi();
|
|
6627
|
+
/* In head/frame mode the hands live in the sealed iframe: open the one
|
|
6628
|
+
bridge to them now that the panel exists. The hands announce
|
|
6629
|
+
themselves (`ready`) when they boot, and the head catches them up
|
|
6630
|
+
then (startHeadBridge). Nothing here touches the iframe's DOM. */
|
|
6631
|
+
if (ROLE === 'head' && FRAME_EL) {
|
|
6632
|
+
/* The seal is the integrator's to set, and the tool cannot enforce
|
|
6633
|
+
it -- it did not create the iframe. But the one misconfiguration
|
|
6634
|
+
that quietly undoes end-to-end safety is worth a word: a sandbox
|
|
6635
|
+
granting allow-same-origin lets the hands reach storage and the
|
|
6636
|
+
host, and no sandbox at all is no seal. A warning, not a refusal. */
|
|
6637
|
+
const sandbox = (FRAME_EL.getAttribute && FRAME_EL.getAttribute('sandbox')) || '';
|
|
6638
|
+
if (!sandbox) {
|
|
6639
|
+
complain('the frame has no sandbox attribute; annotate only '
|
|
6640
|
+
+ 'content you trust, or seal it with sandbox="allow-scripts".');
|
|
6641
|
+
} else if (/(^|\s)allow-same-origin(\s|$)/.test(sandbox)) {
|
|
6642
|
+
complain('the frame\'s sandbox grants allow-same-origin, which '
|
|
6643
|
+
+ 'unseals it: the companion could then reach storage and the '
|
|
6644
|
+
+ 'host. Remove allow-same-origin.');
|
|
6645
|
+
}
|
|
6646
|
+
startHeadBridge(FRAME_EL.contentWindow);
|
|
6647
|
+
}
|
|
6136
6648
|
if (first.ok) {
|
|
6137
6649
|
totals = readTotals(first.data);
|
|
6138
6650
|
retention = readRetention(first.data);
|