@plannotator/ui 0.28.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +6 -0
  2. package/components/AISettingsTab.tsx +5 -4
  3. package/components/ActionMenu.tsx +5 -1
  4. package/components/AgentsTab.tsx +10 -23
  5. package/components/AnnotationPanel.tsx +9 -5
  6. package/components/AnnotationToolbar.tsx +5 -13
  7. package/components/AnnotationToolstrip.tsx +2 -2
  8. package/components/ApproveDropdown.tsx +1 -1
  9. package/components/BlockRenderer.tsx +1 -1
  10. package/components/CodeFilePopout.tsx +5 -4
  11. package/components/CommentPopover.tsx +391 -65
  12. package/components/DocBadges.tsx +29 -11
  13. package/components/ExportModal.tsx +16 -8
  14. package/components/GraphvizBlock.tsx +1 -1
  15. package/components/InlineMarkdown.tsx +30 -13
  16. package/components/KeyboardShortcuts.tsx +37 -2
  17. package/components/Landing.tsx +7 -7
  18. package/components/MenuVersionSection.tsx +4 -4
  19. package/components/MermaidBlock.tsx +1 -1
  20. package/components/ModeToggle.tsx +7 -6
  21. package/components/OpenInAppButton.tsx +2 -5
  22. package/components/PinpointOverlay.tsx +9 -7
  23. package/components/PlanHeaderMenu.tsx +8 -8
  24. package/components/PopoutDialog.tsx +6 -1
  25. package/components/ResizeHandle.tsx +1 -0
  26. package/components/Settings.tsx +172 -12
  27. package/components/SkillReferenceMenu.tsx +260 -0
  28. package/components/StickyHeaderLane.tsx +7 -0
  29. package/components/ThemeProvider.tsx +131 -32
  30. package/components/ThemeTab.tsx +123 -77
  31. package/components/ToolbarButtons.tsx +29 -8
  32. package/components/Viewer.tsx +396 -130
  33. package/components/VimKeyHud.tsx +695 -0
  34. package/components/VimModeAnnouncementDialog.tsx +557 -0
  35. package/components/VimModeOverlay.tsx +235 -0
  36. package/components/VimTargetReticle.tsx +284 -0
  37. package/components/ai/DocumentAIChatPanel.tsx +1 -1
  38. package/components/blocks/CodeBlock.tsx +18 -18
  39. package/components/blocks/TablePopout.tsx +7 -8
  40. package/components/blocks/TableToolbar.tsx +7 -8
  41. package/components/goal-setup/GoalSetupSurface.tsx +16 -3
  42. package/components/html-viewer/HtmlViewer.tsx +450 -47
  43. package/components/html-viewer/annotationNumbering.ts +37 -0
  44. package/components/html-viewer/bridge-script.ts +4051 -298
  45. package/components/html-viewer/composerYield.ts +51 -0
  46. package/components/html-viewer/srcdoc.ts +18 -3
  47. package/components/html-viewer/useHtmlAnnotation.ts +457 -32
  48. package/components/icons/themeIcons.tsx +1 -1
  49. package/components/plan-diff/PlanCleanDiffView.tsx +9 -9
  50. package/components/plan-diff/PlanDiffBadge.tsx +22 -1
  51. package/components/settings/HooksTab.tsx +12 -8
  52. package/components/sidebar/FileBrowser.tsx +4 -1
  53. package/components/themeModes.tsx +28 -0
  54. package/config/configStore.ts +76 -1
  55. package/config/settings.ts +152 -0
  56. package/configure.ts +9 -0
  57. package/globals.d.ts +7 -1
  58. package/hooks/useAIChat.ts +5 -2
  59. package/hooks/useAIProviderActivation.ts +47 -0
  60. package/hooks/useAIProviderConfig.ts +5 -1
  61. package/hooks/useAgentSettings.ts +64 -23
  62. package/hooks/useAgents.ts +4 -4
  63. package/hooks/useAnnotationHighlighter.ts +100 -3
  64. package/hooks/useArchive.ts +2 -1
  65. package/hooks/useFenceTheme.ts +17 -0
  66. package/hooks/useLinkedDoc.ts +68 -1
  67. package/hooks/usePinpoint.ts +76 -75
  68. package/hooks/usePlanDiff.ts +73 -2
  69. package/hooks/useSkillReferenceAutocomplete.ts +239 -0
  70. package/hooks/useUpdateCheck.ts +1 -2
  71. package/hooks/useVimDocumentFocus.ts +116 -0
  72. package/hooks/useVimSelection.ts +1063 -0
  73. package/package.json +4 -4
  74. package/print.css +14 -13
  75. package/shortcuts/core.ts +38 -13
  76. package/shortcuts/index.ts +10 -0
  77. package/shortcuts/plan-review/commentPopover.shortcuts.ts +7 -0
  78. package/shortcuts/plan-review/vimSelection.shortcuts.ts +251 -0
  79. package/shortcuts/runtime.ts +111 -12
  80. package/styles.css +1 -1
  81. package/theme.css +504 -0
  82. package/themes/colorblind.css +89 -0
  83. package/themes/plannotator.css +2 -2
  84. package/types.ts +93 -10
  85. package/utils/agentSwitch.ts +33 -7
  86. package/utils/blockTargeting.ts +462 -178
  87. package/utils/clipboard.ts +110 -0
  88. package/utils/codeBlockMark.ts +50 -0
  89. package/utils/codeHighlight.ts +293 -0
  90. package/utils/codexModels.ts +79 -0
  91. package/utils/domSelection.ts +84 -0
  92. package/utils/htmlChrome.ts +73 -0
  93. package/utils/inputMethod.ts +79 -6
  94. package/utils/parser.ts +517 -21
  95. package/utils/preferenceTtl.ts +15 -0
  96. package/utils/sharing.ts +0 -1
  97. package/utils/skillCatalog.ts +269 -0
  98. package/utils/skillReferences.ts +475 -0
  99. package/utils/syntaxTheme.ts +83 -0
  100. package/utils/themeRegistry.ts +154 -0
  101. package/utils/vimHud.ts +263 -0
  102. package/utils/vimModeAnnouncement.ts +23 -0
  103. package/utils/vimNavigation.ts +417 -0
  104. package/utils/vimReticle.ts +88 -0
  105. package/utils/vimScroll.ts +162 -0
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Composer-yield state machine for shift-click multi-select.
3
+ *
4
+ * While Shift is held during an HTML pinpoint draft, the comment composer must
5
+ * get out of the way of the pointer: fade to ~40% as the pointer approaches,
6
+ * and to near-zero + click-through (pointer-events: none) when the pointer is
7
+ * over it — the DOM equivalent of Codex's setIgnoreMouseEvents click-through
8
+ * popup, so the shift-click lands on the iframe beneath.
9
+ *
10
+ * Restoration uses hysteresis so the composer doesn't flicker at the border:
11
+ * once 'over', the pointer must clear the composer by OVER_EXIT px before the
12
+ * state drops back, and 'near' persists until NEAR_EXIT px (> NEAR_ENTER).
13
+ */
14
+
15
+ export type ComposerYieldState = "none" | "near" | "over";
16
+
17
+ /** Distance (px from the composer rect) at which the composer starts fading. */
18
+ export const COMPOSER_YIELD_NEAR_ENTER_PX = 80;
19
+ /** Distance the pointer must exceed before a faded composer fully restores. */
20
+ export const COMPOSER_YIELD_NEAR_EXIT_PX = 96;
21
+ /** Distance the pointer must clear a click-through composer by to restore. */
22
+ export const COMPOSER_YIELD_OVER_EXIT_PX = 48;
23
+
24
+ /** Shortest distance from a point to a rect's edge; <= 0 means inside. */
25
+ export function distanceToRect(
26
+ x: number,
27
+ y: number,
28
+ rect: { left: number; top: number; right: number; bottom: number },
29
+ ): number {
30
+ const dx = Math.max(rect.left - x, 0, x - rect.right);
31
+ const dy = Math.max(rect.top - y, 0, y - rect.bottom);
32
+ if (dx === 0 && dy === 0) return 0;
33
+ return Math.hypot(dx, dy);
34
+ }
35
+
36
+ /** Next yield state for a pointer at `distance` px from the composer rect. */
37
+ export function computeComposerYield(
38
+ prev: ComposerYieldState,
39
+ distance: number,
40
+ ): ComposerYieldState {
41
+ if (distance <= 0) return "over";
42
+ if (prev === "over") {
43
+ // Hysteresis: don't restore until the pointer has moved well away.
44
+ if (distance <= COMPOSER_YIELD_OVER_EXIT_PX) return "over";
45
+ return distance <= COMPOSER_YIELD_NEAR_EXIT_PX ? "near" : "none";
46
+ }
47
+ if (prev === "near") {
48
+ return distance <= COMPOSER_YIELD_NEAR_EXIT_PX ? "near" : "none";
49
+ }
50
+ return distance <= COMPOSER_YIELD_NEAR_ENTER_PX ? "near" : "none";
51
+ }
@@ -120,11 +120,26 @@ export function buildSrcdocInjection({
120
120
  return `<style>${themeCSS}${ANNOTATION_HIGHLIGHT_CSS}${diffCSS}</style><script>${BRIDGE_SCRIPT}</script>`;
121
121
  }
122
122
 
123
+ /**
124
+ * A document-authored CSP `<meta>` tag (e.g. `default-src 'none'` in
125
+ * Plannotator's own portable guided-review exports) blocks the inline bridge
126
+ * script and disables annotation entirely. The iframe `sandbox` attribute is
127
+ * the security boundary for the annotate surface; the page's CSP was written
128
+ * for its standalone context, so it is removed before injection.
129
+ */
130
+ const META_CSP_RE =
131
+ /<meta\s[^>]*http-equiv\s*=\s*["']?\s*content-security-policy\s*["']?[^>]*\/?>/gi;
132
+
133
+ export function neutralizeMetaCsp(rawHtml: string): string {
134
+ return rawHtml.replace(META_CSP_RE, "<!-- plannotator: meta CSP removed for annotation -->");
135
+ }
136
+
123
137
  /** Splice the injection just before `</head>`, or prepend when there is none. */
124
138
  export function injectIntoHead(rawHtml: string, injection: string): string {
125
- const headClose = rawHtml.indexOf("</head>");
139
+ const html = neutralizeMetaCsp(rawHtml);
140
+ const headClose = html.indexOf("</head>");
126
141
  if (headClose !== -1) {
127
- return rawHtml.slice(0, headClose) + injection + rawHtml.slice(headClose);
142
+ return html.slice(0, headClose) + injection + html.slice(headClose);
128
143
  }
129
- return injection + rawHtml;
144
+ return injection + html;
130
145
  }