@peaske7/readit 0.1.4 → 0.1.6
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/.agents/skills/remotion-best-practices/SKILL.md +61 -0
- package/.agents/skills/remotion-best-practices/rules/3d.md +86 -0
- package/.agents/skills/remotion-best-practices/rules/animations.md +27 -0
- package/.agents/skills/remotion-best-practices/rules/assets/charts-bar-chart.tsx +178 -0
- package/.agents/skills/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +100 -0
- package/.agents/skills/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +108 -0
- package/.agents/skills/remotion-best-practices/rules/assets.md +78 -0
- package/.agents/skills/remotion-best-practices/rules/audio-visualization.md +198 -0
- package/.agents/skills/remotion-best-practices/rules/audio.md +169 -0
- package/.agents/skills/remotion-best-practices/rules/calculate-metadata.md +134 -0
- package/.agents/skills/remotion-best-practices/rules/can-decode.md +75 -0
- package/.agents/skills/remotion-best-practices/rules/charts.md +120 -0
- package/.agents/skills/remotion-best-practices/rules/compositions.md +154 -0
- package/.agents/skills/remotion-best-practices/rules/display-captions.md +184 -0
- package/.agents/skills/remotion-best-practices/rules/extract-frames.md +229 -0
- package/.agents/skills/remotion-best-practices/rules/ffmpeg.md +38 -0
- package/.agents/skills/remotion-best-practices/rules/fonts.md +152 -0
- package/.agents/skills/remotion-best-practices/rules/get-audio-duration.md +58 -0
- package/.agents/skills/remotion-best-practices/rules/get-video-dimensions.md +68 -0
- package/.agents/skills/remotion-best-practices/rules/get-video-duration.md +60 -0
- package/.agents/skills/remotion-best-practices/rules/gifs.md +141 -0
- package/.agents/skills/remotion-best-practices/rules/images.md +134 -0
- package/.agents/skills/remotion-best-practices/rules/import-srt-captions.md +69 -0
- package/.agents/skills/remotion-best-practices/rules/light-leaks.md +73 -0
- package/.agents/skills/remotion-best-practices/rules/lottie.md +70 -0
- package/.agents/skills/remotion-best-practices/rules/maps.md +412 -0
- package/.agents/skills/remotion-best-practices/rules/measuring-dom-nodes.md +34 -0
- package/.agents/skills/remotion-best-practices/rules/measuring-text.md +140 -0
- package/.agents/skills/remotion-best-practices/rules/parameters.md +109 -0
- package/.agents/skills/remotion-best-practices/rules/sequencing.md +118 -0
- package/.agents/skills/remotion-best-practices/rules/sfx.md +26 -0
- package/.agents/skills/remotion-best-practices/rules/subtitles.md +36 -0
- package/.agents/skills/remotion-best-practices/rules/tailwind.md +11 -0
- package/.agents/skills/remotion-best-practices/rules/text-animations.md +20 -0
- package/.agents/skills/remotion-best-practices/rules/timing.md +179 -0
- package/.agents/skills/remotion-best-practices/rules/transcribe-captions.md +70 -0
- package/.agents/skills/remotion-best-practices/rules/transitions.md +197 -0
- package/.agents/skills/remotion-best-practices/rules/transparent-videos.md +106 -0
- package/.agents/skills/remotion-best-practices/rules/trimming.md +51 -0
- package/.agents/skills/remotion-best-practices/rules/videos.md +171 -0
- package/.agents/skills/remotion-best-practices/rules/voiceover.md +99 -0
- package/.agents/skills/simple/SKILL.md +52 -0
- package/.agents/skills/vercel-react-best-practices/AGENTS.md +3254 -0
- package/.agents/skills/vercel-react-best-practices/README.md +123 -0
- package/.agents/skills/vercel-react-best-practices/SKILL.md +141 -0
- package/.agents/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/.agents/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
- package/.agents/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-flatmap-filter.md +60 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-resource-hints.md +85 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-script-defer-async.md +68 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-no-inline-components.md +82 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-hoist-static-io.md +142 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
- package/.claude/CLAUDE.md +142 -0
- package/.claude/commands/review.md +120 -0
- package/.claude/commands/sync-docs.md +71 -0
- package/.claude/roadmap.md +98 -0
- package/.claude/rules/style-guide.md +830 -0
- package/.claude/settings.json +18 -0
- package/.claude/user-stories.md +248 -0
- package/AGENTS.md +64 -0
- package/README.md +7 -7
- package/biome.json +69 -0
- package/bun.lock +1124 -0
- package/docs/design.md +563 -0
- package/docs/plans/2026-03-13-client-mode-design.md +86 -0
- package/docs/plans/2026-03-13-client-mode-plan.md +605 -0
- package/docs/plans/2026-03-13-keyboard-shortcuts-design.md +129 -0
- package/docs/plans/2026-03-13-keyboard-shortcuts-plan.md +1471 -0
- package/docs/plans/2026-03-13-multi-document-design.md +183 -0
- package/docs/plans/2026-03-13-performance-benchmarks-design.md +121 -0
- package/e2e/comments.spec.ts +125 -0
- package/e2e/document-load.spec.ts +54 -0
- package/e2e/export.spec.ts +58 -0
- package/e2e/fixtures/sample.html +13 -0
- package/e2e/fixtures/sample.md +7 -0
- package/e2e/persistence-file.spec.ts +342 -0
- package/e2e/utils/cli.ts +84 -0
- package/e2e/utils/selection.ts +135 -0
- package/{dist/index.html → index.html} +8 -2
- package/lefthook.yml +8 -0
- package/package.json +17 -39
- package/playwright.config.ts +22 -0
- package/skills-lock.json +20 -0
- package/src/App.tsx +396 -0
- package/src/cli/index.ts +467 -0
- package/src/components/ActionsMenu.tsx +110 -0
- package/src/components/DocumentViewer/CodeBlock.tsx +83 -0
- package/src/components/DocumentViewer/DocumentViewer.tsx +257 -0
- package/src/components/DocumentViewer/IframeContainer.tsx +251 -0
- package/src/components/DocumentViewer/MermaidDiagram.tsx +137 -0
- package/src/components/DocumentViewer/index.ts +1 -0
- package/src/components/FloatingTOC.tsx +59 -0
- package/src/components/Header.tsx +63 -0
- package/src/components/InlineEditor.tsx +72 -0
- package/src/components/MarginNote.tsx +198 -0
- package/src/components/MarginNotes.tsx +50 -0
- package/src/components/RawModal.tsx +141 -0
- package/src/components/ReanchorConfirm.tsx +33 -0
- package/src/components/SettingsModal.tsx +221 -0
- package/src/components/ShortcutCapture.tsx +45 -0
- package/src/components/ShortcutList.tsx +157 -0
- package/src/components/TabBar.tsx +60 -0
- package/src/components/TableOfContents.tsx +108 -0
- package/src/components/comments/CommentBadge.tsx +43 -0
- package/src/components/comments/CommentInput.tsx +119 -0
- package/src/components/comments/CommentListItem.tsx +82 -0
- package/src/components/comments/CommentManager.tsx +106 -0
- package/src/components/comments/CommentMinimap.tsx +62 -0
- package/src/components/comments/CommentNav.tsx +104 -0
- package/src/components/ui/ActionBar.tsx +16 -0
- package/src/components/ui/ActionLink.tsx +32 -0
- package/src/components/ui/Button.tsx +55 -0
- package/src/components/ui/Dialog.tsx +156 -0
- package/src/components/ui/DropdownMenu.tsx +114 -0
- package/src/components/ui/SeparatorDot.tsx +9 -0
- package/src/components/ui/Text.tsx +54 -0
- package/src/contexts/CommentContext.tsx +222 -0
- package/src/contexts/LayoutContext.tsx +76 -0
- package/src/hooks/useClickOutside.ts +35 -0
- package/src/hooks/useClipboard.ts +79 -0
- package/src/hooks/useCommentNavigation.ts +130 -0
- package/src/hooks/useComments.ts +323 -0
- package/src/hooks/useDocument.ts +141 -0
- package/src/hooks/useFontPreference.ts +76 -0
- package/src/hooks/useHeadings.test.ts +159 -0
- package/src/hooks/useHeadings.ts +129 -0
- package/src/hooks/useKeybindings.ts +120 -0
- package/src/hooks/useKeyboardShortcuts.ts +63 -0
- package/src/hooks/useLayoutMode.ts +44 -0
- package/src/hooks/useReanchorMode.ts +33 -0
- package/src/hooks/useScrollMetrics.ts +56 -0
- package/src/hooks/useScrollSpy.ts +81 -0
- package/src/hooks/useTextSelection.ts +123 -0
- package/src/hooks/useThemePreference.ts +66 -0
- package/src/index.css +823 -0
- package/src/lib/__fixtures__/bench-data.ts +167 -0
- package/src/lib/anchor.bench.ts +112 -0
- package/src/lib/anchor.test.ts +531 -0
- package/src/lib/anchor.ts +465 -0
- package/src/lib/comment-storage.bench.ts +63 -0
- package/src/lib/comment-storage.test.ts +624 -0
- package/src/lib/comment-storage.ts +263 -0
- package/src/lib/context.bench.ts +41 -0
- package/src/lib/context.test.ts +224 -0
- package/src/lib/context.ts +193 -0
- package/src/lib/export.bench.ts +35 -0
- package/src/lib/export.ts +43 -0
- package/src/lib/highlight/colors.ts +37 -0
- package/src/lib/highlight/core.test.ts +98 -0
- package/src/lib/highlight/core.ts +54 -0
- package/src/lib/highlight/dom.ts +342 -0
- package/src/lib/highlight/highlighter.ts +427 -0
- package/src/lib/highlight/index.ts +23 -0
- package/src/lib/highlight/script-builder.ts +485 -0
- package/src/lib/highlight/types.ts +57 -0
- package/src/lib/html-processor.test.tsx +170 -0
- package/src/lib/html-processor.tsx +95 -0
- package/src/lib/layout-constants.ts +12 -0
- package/src/lib/margin-layout.bench.ts +28 -0
- package/src/lib/margin-layout.ts +100 -0
- package/src/lib/scroll.test.ts +118 -0
- package/src/lib/scroll.ts +47 -0
- package/src/lib/shortcut-registry.test.ts +173 -0
- package/src/lib/shortcut-registry.ts +209 -0
- package/src/lib/utils.test.ts +110 -0
- package/src/lib/utils.ts +61 -0
- package/src/main.tsx +10 -0
- package/src/server/index.ts +883 -0
- package/src/store/index.test.ts +220 -0
- package/src/store/index.ts +234 -0
- package/src/test-setup.ts +1 -0
- package/src/types/index.ts +115 -0
- package/test.md +74 -0
- package/tsconfig.cli.json +12 -0
- package/tsconfig.json +20 -0
- package/vite.config.ts +19 -0
- package/vitest.config.ts +15 -0
- package/dist/assets/_basePickBy-hOr-yGsE.js +0 -1
- package/dist/assets/_baseUniq-b7bzdUSn.js +0 -1
- package/dist/assets/arc-D65wG9gm.js +0 -1
- package/dist/assets/architecture-PBZL5I3N-DBa6CAv_.js +0 -1
- package/dist/assets/architectureDiagram-2XIMDMQ5-Djwpsh98.js +0 -36
- package/dist/assets/array-DOVTz2Mq.js +0 -1
- package/dist/assets/blockDiagram-WCTKOSBZ-BdW5TTxj.js +0 -132
- package/dist/assets/c4Diagram-IC4MRINW-DTmkHEXu.js +0 -10
- package/dist/assets/channel-B3MUFipN.js +0 -1
- package/dist/assets/chunk-4BX2VUAB-DEqzsvDc.js +0 -1
- package/dist/assets/chunk-55IACEB6-BzVuSUV8.js +0 -1
- package/dist/assets/chunk-7E7YKBS2-CZ8IcA4c.js +0 -1
- package/dist/assets/chunk-7R4GIKGN-CWVVC8HX.js +0 -79
- package/dist/assets/chunk-C72U2L5F-B1Tso5TH.js +0 -1
- package/dist/assets/chunk-EGIJ26TM-Cx_7CFik.js +0 -1
- package/dist/assets/chunk-FMBD7UC4-Cfk_iGhv.js +0 -15
- package/dist/assets/chunk-GEFDOKGD-C_5hRbJt.js +0 -2
- package/dist/assets/chunk-GLR3WWYH-CkY7IyBj.js +0 -2
- package/dist/assets/chunk-HHEYEP7N-B0I4X5cr.js +0 -1
- package/dist/assets/chunk-JSJVCQXG-CAjwlVLg.js +0 -1
- package/dist/assets/chunk-KX2RTZJC-DWqnZZ02.js +0 -1
- package/dist/assets/chunk-KYZI473N-gjRVhJgJ.js +0 -53
- package/dist/assets/chunk-L3YUKLVL-D7C9GuxL.js +0 -1
- package/dist/assets/chunk-MX3YWQON-i-77iuVj.js +0 -1
- package/dist/assets/chunk-NQ4KR5QH-B22Pvemm.js +0 -220
- package/dist/assets/chunk-O4XLMI2P-ZQd5L6ZD.js +0 -7
- package/dist/assets/chunk-OZEHJAEY-BaPKTELw.js +0 -1
- package/dist/assets/chunk-PQ6SQG4A-DqE1eupT.js +0 -1
- package/dist/assets/chunk-PU5JKC2W-BTqWqedh.js +0 -70
- package/dist/assets/chunk-QZHKN3VN-Nm9TvMss.js +0 -1
- package/dist/assets/chunk-R5LLSJPH-DkiNs1dN.js +0 -1
- package/dist/assets/chunk-WL4C6EOR-CioD2fv2.js +0 -189
- package/dist/assets/chunk-XIRO2GV7-B4GGQONY.js +0 -1
- package/dist/assets/chunk-XPW4576I-C0IbbQos.js +0 -32
- package/dist/assets/chunk-XZSTWKYB-DMOqFWmT.js +0 -94
- package/dist/assets/chunk-YBOYWFTD-CoeQgeVY.js +0 -1
- package/dist/assets/classDiagram-VBA2DB6C-DV9ltQ7h.js +0 -1
- package/dist/assets/classDiagram-v2-RAHNMMFH-C6nD9wmM.js +0 -1
- package/dist/assets/clone-DuY6BQEm.js +0 -1
- package/dist/assets/cose-bilkent-S5V4N54A-B6FexK6p.js +0 -1
- package/dist/assets/cytoscape.esm-DoTFyJaN.js +0 -321
- package/dist/assets/dagre-CCcocoCU.js +0 -1
- package/dist/assets/dagre-KLK3FWXG-DIELowj9.js +0 -4
- package/dist/assets/defaultLocale-Ck2Xxk-C.js +0 -1
- package/dist/assets/diagram-E7M64L7V-D1mm0PoO.js +0 -24
- package/dist/assets/diagram-IFDJBPK2-7DVjly8y.js +0 -43
- package/dist/assets/diagram-P4PSJMXO-jO7pfyMb.js +0 -24
- package/dist/assets/dist-BywRdrPx.js +0 -1
- package/dist/assets/erDiagram-INFDFZHY-DSRxlRFy.js +0 -70
- package/dist/assets/flowDiagram-PKNHOUZH-CgKzzNdR.js +0 -162
- package/dist/assets/ganttDiagram-A5KZAMGK-CtsE7Y4E.js +0 -292
- package/dist/assets/gitGraph-HDMCJU4V-BU9uhwtz.js +0 -1
- package/dist/assets/gitGraphDiagram-K3NZZRJ6-DOU8RGdw.js +0 -65
- package/dist/assets/graphlib-WkJoBgka.js +0 -1
- package/dist/assets/index-CKVArt9D.js +0 -562
- package/dist/assets/index-DzRKJazf.css +0 -2
- package/dist/assets/info-3K5VOQVL-CPpvM-SG.js +0 -1
- package/dist/assets/infoDiagram-LFFYTUFH-VKLs5DsF.js +0 -2
- package/dist/assets/init-Bft5Ffpj.js +0 -1
- package/dist/assets/isArrayLikeObject-icl0H0jo.js +0 -1
- package/dist/assets/isEmpty-Du8sNmkE.js +0 -1
- package/dist/assets/ishikawaDiagram-PHBUUO56-CsWvEjux.js +0 -70
- package/dist/assets/journeyDiagram-4ABVD52K-BzJGTdIT.js +0 -139
- package/dist/assets/kanban-definition-K7BYSVSG-B_9ClJ1A.js +0 -89
- package/dist/assets/katex-BJrMXEjr.js +0 -261
- package/dist/assets/line-CC_tDGId.js +0 -1
- package/dist/assets/linear-Cts_d04Y.js +0 -1
- package/dist/assets/math-CNhlSIO3.js +0 -1
- package/dist/assets/mermaid-parser.core-Vb9KKv1R.js +0 -4
- package/dist/assets/mermaid.core-C_7xsp3d.js +0 -11
- package/dist/assets/mindmap-definition-YRQLILUH-BWmfy5wB.js +0 -68
- package/dist/assets/ordinal-DIg8h6NI.js +0 -1
- package/dist/assets/packet-RMMSAZCW-Q-WG6o3b.js +0 -1
- package/dist/assets/path-DfRbCp9y.js +0 -1
- package/dist/assets/pie-UPGHQEXC-Cwi2tLlt.js +0 -1
- package/dist/assets/pieDiagram-SKSYHLDU-Dyf3X_in.js +0 -30
- package/dist/assets/quadrantDiagram-337W2JSQ-B5_5m61Q.js +0 -7
- package/dist/assets/radar-KQ55EAFF-Dtw2VzxY.js +0 -1
- package/dist/assets/requirementDiagram-Z7DCOOCP-BSERBnlW.js +0 -73
- package/dist/assets/rough.esm-KjoEK0it.js +0 -1
- package/dist/assets/sankeyDiagram-WA2Y5GQK-CMcEY8Cz.js +0 -10
- package/dist/assets/sequenceDiagram-2WXFIKYE-D28qcXwC.js +0 -145
- package/dist/assets/src-C8kkzlHX.js +0 -1
- package/dist/assets/stateDiagram-RAJIS63D-7oVrCmRl.js +0 -1
- package/dist/assets/stateDiagram-v2-FVOUBMTO-DtFptQAd.js +0 -1
- package/dist/assets/timeline-definition-YZTLITO2-rbCfBEvG.js +0 -61
- package/dist/assets/treemap-KZPCXAKY-BlRvF0um.js +0 -1
- package/dist/assets/vennDiagram-LZ73GAT5-DBit3zWa.js +0 -34
- package/dist/assets/xychartDiagram-JWTSCODW-BVYXv51y.js +0 -7
- package/dist/index.js +0 -1040
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
2
|
+
import { X } from "lucide-react";
|
|
3
|
+
import { use } from "react";
|
|
4
|
+
import { LayoutContext } from "../../contexts/LayoutContext";
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
import { FontFamilies } from "../../types";
|
|
7
|
+
import { buttonVariants } from "./Button";
|
|
8
|
+
import { textVariants } from "./Text";
|
|
9
|
+
|
|
10
|
+
function Dialog({
|
|
11
|
+
...props
|
|
12
|
+
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
|
13
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function DialogTrigger({
|
|
17
|
+
...props
|
|
18
|
+
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
|
19
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function DialogPortal({
|
|
23
|
+
...props
|
|
24
|
+
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
|
25
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function DialogClose({
|
|
29
|
+
...props
|
|
30
|
+
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
|
31
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function DialogOverlay({
|
|
35
|
+
className,
|
|
36
|
+
...props
|
|
37
|
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
38
|
+
return (
|
|
39
|
+
<DialogPrimitive.Overlay
|
|
40
|
+
data-slot="dialog-overlay"
|
|
41
|
+
className={cn(
|
|
42
|
+
"fixed inset-0 z-50 bg-black/20 dark:bg-black/40 backdrop-blur-sm",
|
|
43
|
+
className,
|
|
44
|
+
)}
|
|
45
|
+
{...props}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function DialogContent({
|
|
51
|
+
className,
|
|
52
|
+
children,
|
|
53
|
+
showCloseButton = true,
|
|
54
|
+
...props
|
|
55
|
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
56
|
+
showCloseButton?: boolean;
|
|
57
|
+
}) {
|
|
58
|
+
return (
|
|
59
|
+
<DialogPortal>
|
|
60
|
+
<DialogOverlay />
|
|
61
|
+
<DialogPrimitive.Content
|
|
62
|
+
data-slot="dialog-content"
|
|
63
|
+
className={cn(
|
|
64
|
+
"fixed top-1/2 left-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2",
|
|
65
|
+
"bg-white/95 dark:bg-zinc-900/95 backdrop-blur-sm shadow-lg border border-zinc-200/40 dark:border-zinc-700/40 rounded-xl",
|
|
66
|
+
"flex flex-col animate-in",
|
|
67
|
+
className,
|
|
68
|
+
)}
|
|
69
|
+
{...props}
|
|
70
|
+
>
|
|
71
|
+
{children}
|
|
72
|
+
{showCloseButton && (
|
|
73
|
+
<DialogPrimitive.Close
|
|
74
|
+
data-slot="dialog-close"
|
|
75
|
+
className={cn(
|
|
76
|
+
buttonVariants({ variant: "ghost", size: "icon" }),
|
|
77
|
+
"absolute top-3 right-3 size-7",
|
|
78
|
+
)}
|
|
79
|
+
>
|
|
80
|
+
<X className="w-4 h-4" />
|
|
81
|
+
<span className="sr-only">Close</span>
|
|
82
|
+
</DialogPrimitive.Close>
|
|
83
|
+
)}
|
|
84
|
+
</DialogPrimitive.Content>
|
|
85
|
+
</DialogPortal>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
90
|
+
return (
|
|
91
|
+
<div
|
|
92
|
+
data-slot="dialog-header"
|
|
93
|
+
className={cn(
|
|
94
|
+
"flex items-center justify-between pl-4 pr-12 py-3 border-b border-zinc-100 dark:border-zinc-800",
|
|
95
|
+
className,
|
|
96
|
+
)}
|
|
97
|
+
{...props}
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function DialogTitle({
|
|
103
|
+
className,
|
|
104
|
+
...props
|
|
105
|
+
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
|
106
|
+
const layout = use(LayoutContext);
|
|
107
|
+
const fontClass = layout
|
|
108
|
+
? layout.fontFamily === FontFamilies.SANS_SERIF
|
|
109
|
+
? "font-sans"
|
|
110
|
+
: "font-serif"
|
|
111
|
+
: undefined;
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<DialogPrimitive.Title
|
|
115
|
+
data-slot="dialog-title"
|
|
116
|
+
className={cn(textVariants({ variant: "section" }), fontClass, className)}
|
|
117
|
+
{...props}
|
|
118
|
+
/>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function DialogDescription({
|
|
123
|
+
className,
|
|
124
|
+
...props
|
|
125
|
+
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
|
126
|
+
return (
|
|
127
|
+
<DialogPrimitive.Description
|
|
128
|
+
data-slot="dialog-description"
|
|
129
|
+
className={cn(textVariants({ variant: "caption" }), "text-sm", className)}
|
|
130
|
+
{...props}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function DialogBody({ className, ...props }: React.ComponentProps<"div">) {
|
|
136
|
+
return (
|
|
137
|
+
<div
|
|
138
|
+
data-slot="dialog-body"
|
|
139
|
+
className={cn("flex-1 overflow-auto p-4", className)}
|
|
140
|
+
{...props}
|
|
141
|
+
/>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export {
|
|
146
|
+
Dialog,
|
|
147
|
+
DialogBody,
|
|
148
|
+
DialogClose,
|
|
149
|
+
DialogContent,
|
|
150
|
+
DialogDescription,
|
|
151
|
+
DialogHeader,
|
|
152
|
+
DialogOverlay,
|
|
153
|
+
DialogPortal,
|
|
154
|
+
DialogTitle,
|
|
155
|
+
DialogTrigger,
|
|
156
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
2
|
+
import { cn } from "../../lib/utils";
|
|
3
|
+
import { textVariants } from "./Text";
|
|
4
|
+
|
|
5
|
+
function DropdownMenu({
|
|
6
|
+
...props
|
|
7
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
|
8
|
+
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function DropdownMenuTrigger({
|
|
12
|
+
...props
|
|
13
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
|
|
14
|
+
return (
|
|
15
|
+
<DropdownMenuPrimitive.Trigger
|
|
16
|
+
data-slot="dropdown-menu-trigger"
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function DropdownMenuContent({
|
|
23
|
+
className,
|
|
24
|
+
sideOffset = 4,
|
|
25
|
+
...props
|
|
26
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
|
|
27
|
+
return (
|
|
28
|
+
<DropdownMenuPrimitive.Portal>
|
|
29
|
+
<DropdownMenuPrimitive.Content
|
|
30
|
+
data-slot="dropdown-menu-content"
|
|
31
|
+
sideOffset={sideOffset}
|
|
32
|
+
className={cn(
|
|
33
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-xl py-1",
|
|
34
|
+
"bg-white/95 dark:bg-zinc-900/95 backdrop-blur-sm shadow-lg border border-zinc-200/40 dark:border-zinc-700/40",
|
|
35
|
+
"animate-in",
|
|
36
|
+
className,
|
|
37
|
+
)}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
</DropdownMenuPrimitive.Portal>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function DropdownMenuGroup({
|
|
45
|
+
...props
|
|
46
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
|
|
47
|
+
return (
|
|
48
|
+
<DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function DropdownMenuItem({
|
|
53
|
+
className,
|
|
54
|
+
variant = "default",
|
|
55
|
+
...props
|
|
56
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
|
57
|
+
variant?: "default" | "destructive";
|
|
58
|
+
}) {
|
|
59
|
+
return (
|
|
60
|
+
<DropdownMenuPrimitive.Item
|
|
61
|
+
data-slot="dropdown-menu-item"
|
|
62
|
+
data-variant={variant}
|
|
63
|
+
className={cn(
|
|
64
|
+
"w-full px-3 py-1.5 text-left text-sm outline-none select-none transition-colors duration-150 flex items-center gap-2 cursor-default",
|
|
65
|
+
"data-[variant=default]:text-zinc-600 dark:data-[variant=default]:text-zinc-400 data-[variant=default]:focus:bg-zinc-50 dark:data-[variant=default]:focus:bg-zinc-800 data-[variant=default]:focus:text-zinc-900 dark:data-[variant=default]:focus:text-zinc-100",
|
|
66
|
+
"data-[variant=destructive]:text-red-600 dark:data-[variant=destructive]:text-red-400 data-[variant=destructive]:focus:bg-red-50 dark:data-[variant=destructive]:focus:bg-red-950 data-[variant=destructive]:focus:text-red-700 dark:data-[variant=destructive]:focus:text-red-300",
|
|
67
|
+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
68
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
|
|
69
|
+
className,
|
|
70
|
+
)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function DropdownMenuSeparator({
|
|
77
|
+
className,
|
|
78
|
+
...props
|
|
79
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
|
|
80
|
+
return (
|
|
81
|
+
<DropdownMenuPrimitive.Separator
|
|
82
|
+
data-slot="dropdown-menu-separator"
|
|
83
|
+
className={cn("my-1 h-px bg-zinc-100 dark:bg-zinc-800", className)}
|
|
84
|
+
{...props}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function DropdownMenuLabel({
|
|
90
|
+
className,
|
|
91
|
+
...props
|
|
92
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Label>) {
|
|
93
|
+
return (
|
|
94
|
+
<DropdownMenuPrimitive.Label
|
|
95
|
+
data-slot="dropdown-menu-label"
|
|
96
|
+
className={cn(
|
|
97
|
+
"px-3 py-1.5 font-medium",
|
|
98
|
+
textVariants({ variant: "caption" }),
|
|
99
|
+
className,
|
|
100
|
+
)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
DropdownMenu,
|
|
108
|
+
DropdownMenuContent,
|
|
109
|
+
DropdownMenuGroup,
|
|
110
|
+
DropdownMenuItem,
|
|
111
|
+
DropdownMenuLabel,
|
|
112
|
+
DropdownMenuSeparator,
|
|
113
|
+
DropdownMenuTrigger,
|
|
114
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { use } from "react";
|
|
4
|
+
import { LayoutContext } from "../../contexts/LayoutContext";
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
import { FontFamilies } from "../../types";
|
|
7
|
+
|
|
8
|
+
const textVariants = cva("", {
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
title:
|
|
12
|
+
"text-lg font-semibold tracking-tight text-zinc-900 dark:text-zinc-100",
|
|
13
|
+
section: "text-sm font-medium text-zinc-900 dark:text-zinc-100",
|
|
14
|
+
subsection: "text-xs font-medium text-zinc-700 dark:text-zinc-300",
|
|
15
|
+
overline:
|
|
16
|
+
"text-xs font-medium text-zinc-500 dark:text-zinc-400 uppercase tracking-wider",
|
|
17
|
+
body: "text-sm text-zinc-600 dark:text-zinc-400",
|
|
18
|
+
caption: "text-xs text-zinc-500 dark:text-zinc-400",
|
|
19
|
+
micro: "text-[10px] text-zinc-400 dark:text-zinc-500",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
variant: "body",
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
function Text({
|
|
28
|
+
className,
|
|
29
|
+
variant,
|
|
30
|
+
asChild = false,
|
|
31
|
+
...props
|
|
32
|
+
}: React.ComponentProps<"p"> &
|
|
33
|
+
VariantProps<typeof textVariants> & {
|
|
34
|
+
asChild?: boolean;
|
|
35
|
+
}) {
|
|
36
|
+
const layout = use(LayoutContext);
|
|
37
|
+
const fontClass = layout
|
|
38
|
+
? layout.fontFamily === FontFamilies.SANS_SERIF
|
|
39
|
+
? "font-sans"
|
|
40
|
+
: "font-serif"
|
|
41
|
+
: undefined;
|
|
42
|
+
|
|
43
|
+
const Comp = asChild ? Slot : "p";
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Comp
|
|
47
|
+
data-slot="text"
|
|
48
|
+
className={cn(fontClass, textVariants({ variant }), className)}
|
|
49
|
+
{...props}
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { Text, textVariants };
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
type ReactNode,
|
|
4
|
+
use,
|
|
5
|
+
useCallback,
|
|
6
|
+
useEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
} from "react";
|
|
9
|
+
import { toast } from "sonner";
|
|
10
|
+
import { useCommentNavigation } from "../hooks/useCommentNavigation";
|
|
11
|
+
import { useComments } from "../hooks/useComments";
|
|
12
|
+
import { useReanchorMode } from "../hooks/useReanchorMode";
|
|
13
|
+
import { extractContext, formatForLLM } from "../lib/context";
|
|
14
|
+
import { generatePrompt } from "../lib/export";
|
|
15
|
+
import { truncate } from "../lib/utils";
|
|
16
|
+
import { useAppStore } from "../store";
|
|
17
|
+
import type { Comment, DocumentType } from "../types";
|
|
18
|
+
|
|
19
|
+
interface CommentContextValue {
|
|
20
|
+
// From useComments
|
|
21
|
+
comments: Comment[];
|
|
22
|
+
commentCount: number;
|
|
23
|
+
addComment: (
|
|
24
|
+
selectedText: string,
|
|
25
|
+
comment: string,
|
|
26
|
+
startOffset: number,
|
|
27
|
+
endOffset: number,
|
|
28
|
+
) => void;
|
|
29
|
+
editComment: (id: string, newText: string) => void;
|
|
30
|
+
deleteComment: (id: string) => void;
|
|
31
|
+
deleteAll: () => void;
|
|
32
|
+
reanchorComment: (
|
|
33
|
+
id: string,
|
|
34
|
+
selectedText: string,
|
|
35
|
+
startOffset: number,
|
|
36
|
+
endOffset: number,
|
|
37
|
+
) => void;
|
|
38
|
+
// Derived
|
|
39
|
+
sortedComments: Comment[];
|
|
40
|
+
// From useCommentNavigation
|
|
41
|
+
currentIndex: number;
|
|
42
|
+
hoveredCommentId: string | undefined;
|
|
43
|
+
setHoveredCommentId: (id: string | undefined) => void;
|
|
44
|
+
navigateToComment: (commentId: string) => void;
|
|
45
|
+
navigatePrevious: () => void;
|
|
46
|
+
navigateNext: () => void;
|
|
47
|
+
// From useReanchorMode
|
|
48
|
+
reanchorTarget: { commentId: string } | null;
|
|
49
|
+
startReanchor: (commentId: string) => void;
|
|
50
|
+
cancelReanchor: () => void;
|
|
51
|
+
// Copy operations
|
|
52
|
+
copyCommentRaw: (comment: Comment) => void;
|
|
53
|
+
copyCommentForLLM: (comment: Comment) => void;
|
|
54
|
+
copyAllForLLM: () => void;
|
|
55
|
+
// Scroll to highlight
|
|
56
|
+
scrollToHighlight: (commentId: string) => void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const CommentContext = createContext<CommentContextValue | null>(null);
|
|
60
|
+
|
|
61
|
+
export function useCommentContext(): CommentContextValue {
|
|
62
|
+
const value = use(CommentContext);
|
|
63
|
+
if (!value) {
|
|
64
|
+
throw new Error("useCommentContext must be used within a CommentProvider");
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface CommentProviderProps {
|
|
70
|
+
filePath: string;
|
|
71
|
+
clean: boolean;
|
|
72
|
+
documentContent: string;
|
|
73
|
+
fileName: string;
|
|
74
|
+
documentType: DocumentType;
|
|
75
|
+
children: ReactNode;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function CommentProvider({
|
|
79
|
+
filePath,
|
|
80
|
+
clean,
|
|
81
|
+
documentContent,
|
|
82
|
+
fileName,
|
|
83
|
+
documentType,
|
|
84
|
+
children,
|
|
85
|
+
}: CommentProviderProps) {
|
|
86
|
+
const {
|
|
87
|
+
comments,
|
|
88
|
+
error: commentsError,
|
|
89
|
+
addComment,
|
|
90
|
+
deleteComment,
|
|
91
|
+
deleteAll,
|
|
92
|
+
editComment,
|
|
93
|
+
reanchorComment,
|
|
94
|
+
} = useComments(filePath, { clean });
|
|
95
|
+
|
|
96
|
+
// sortedComments from store (already sorted by setComments)
|
|
97
|
+
const sortedComments = useAppStore(
|
|
98
|
+
(s) => s.documents.get(filePath)?.sortedComments ?? [],
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const {
|
|
102
|
+
currentIndex,
|
|
103
|
+
hoveredCommentId,
|
|
104
|
+
setHoveredCommentId,
|
|
105
|
+
navigateToComment,
|
|
106
|
+
navigatePrevious,
|
|
107
|
+
navigateNext,
|
|
108
|
+
} = useCommentNavigation(sortedComments);
|
|
109
|
+
|
|
110
|
+
const { reanchorTarget, startReanchor, cancelReanchor } = useReanchorMode();
|
|
111
|
+
|
|
112
|
+
// Show comments errors as toast
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (commentsError) {
|
|
115
|
+
toast.error(commentsError);
|
|
116
|
+
}
|
|
117
|
+
}, [commentsError]);
|
|
118
|
+
|
|
119
|
+
const copyCommentRaw = useCallback((comment: Comment) => {
|
|
120
|
+
const raw = `${comment.selectedText}\n\n${comment.comment}`;
|
|
121
|
+
navigator.clipboard.writeText(raw);
|
|
122
|
+
toast.success(`Copied: "${truncate(comment.comment)}"`);
|
|
123
|
+
}, []);
|
|
124
|
+
|
|
125
|
+
const copyCommentForLLM = useCallback(
|
|
126
|
+
(comment: Comment) => {
|
|
127
|
+
const context = extractContext({
|
|
128
|
+
content: documentContent,
|
|
129
|
+
startOffset: comment.startOffset,
|
|
130
|
+
endOffset: comment.endOffset,
|
|
131
|
+
});
|
|
132
|
+
const formatted = formatForLLM({
|
|
133
|
+
context,
|
|
134
|
+
fileName,
|
|
135
|
+
comment: comment.comment,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
navigator.clipboard.writeText(formatted);
|
|
139
|
+
toast.success(`Copied for LLM: "${truncate(comment.comment)}"`);
|
|
140
|
+
},
|
|
141
|
+
[documentContent, fileName],
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
const copyAllForLLM = useCallback(() => {
|
|
145
|
+
const prompt = generatePrompt(comments, fileName);
|
|
146
|
+
navigator.clipboard.writeText(prompt);
|
|
147
|
+
toast.success("Copied all comments");
|
|
148
|
+
}, [comments, fileName]);
|
|
149
|
+
|
|
150
|
+
const scrollToHighlight = useCallback(
|
|
151
|
+
(commentId: string) => {
|
|
152
|
+
if (documentType === "html") {
|
|
153
|
+
const iframe = window.document.querySelector("iframe");
|
|
154
|
+
iframe?.contentWindow?.postMessage(
|
|
155
|
+
{ type: "scrollToHighlight", commentId },
|
|
156
|
+
"*",
|
|
157
|
+
);
|
|
158
|
+
} else {
|
|
159
|
+
const mark = window.document.querySelector(
|
|
160
|
+
`mark[data-comment-id="${commentId}"]`,
|
|
161
|
+
);
|
|
162
|
+
if (mark) {
|
|
163
|
+
mark.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
[documentType],
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const commentCount = comments.length;
|
|
171
|
+
|
|
172
|
+
const value = useMemo<CommentContextValue>(
|
|
173
|
+
() => ({
|
|
174
|
+
comments,
|
|
175
|
+
commentCount,
|
|
176
|
+
addComment,
|
|
177
|
+
editComment,
|
|
178
|
+
deleteComment,
|
|
179
|
+
deleteAll,
|
|
180
|
+
reanchorComment,
|
|
181
|
+
sortedComments,
|
|
182
|
+
currentIndex,
|
|
183
|
+
hoveredCommentId,
|
|
184
|
+
setHoveredCommentId,
|
|
185
|
+
navigateToComment,
|
|
186
|
+
navigatePrevious,
|
|
187
|
+
navigateNext,
|
|
188
|
+
reanchorTarget,
|
|
189
|
+
startReanchor,
|
|
190
|
+
cancelReanchor,
|
|
191
|
+
copyCommentRaw,
|
|
192
|
+
copyCommentForLLM,
|
|
193
|
+
copyAllForLLM,
|
|
194
|
+
scrollToHighlight,
|
|
195
|
+
}),
|
|
196
|
+
[
|
|
197
|
+
comments,
|
|
198
|
+
commentCount,
|
|
199
|
+
addComment,
|
|
200
|
+
editComment,
|
|
201
|
+
deleteComment,
|
|
202
|
+
deleteAll,
|
|
203
|
+
reanchorComment,
|
|
204
|
+
sortedComments,
|
|
205
|
+
currentIndex,
|
|
206
|
+
hoveredCommentId,
|
|
207
|
+
setHoveredCommentId,
|
|
208
|
+
navigateToComment,
|
|
209
|
+
navigatePrevious,
|
|
210
|
+
navigateNext,
|
|
211
|
+
reanchorTarget,
|
|
212
|
+
startReanchor,
|
|
213
|
+
cancelReanchor,
|
|
214
|
+
copyCommentRaw,
|
|
215
|
+
copyCommentForLLM,
|
|
216
|
+
copyAllForLLM,
|
|
217
|
+
scrollToHighlight,
|
|
218
|
+
],
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
return <CommentContext value={value}>{children}</CommentContext>;
|
|
222
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { createContext, type ReactNode, use, useMemo } from "react";
|
|
2
|
+
import { useFontPreference } from "../hooks/useFontPreference";
|
|
3
|
+
import { useKeybindings } from "../hooks/useKeybindings";
|
|
4
|
+
import { useLayoutMode } from "../hooks/useLayoutMode";
|
|
5
|
+
import { useThemePreference } from "../hooks/useThemePreference";
|
|
6
|
+
import type { ShortcutDefinition } from "../lib/shortcut-registry";
|
|
7
|
+
import type { FontFamily, ShortcutBinding, ThemeMode } from "../types";
|
|
8
|
+
|
|
9
|
+
interface LayoutContextValue {
|
|
10
|
+
isFullscreen: boolean;
|
|
11
|
+
toggleLayoutMode: () => void;
|
|
12
|
+
fontFamily: FontFamily;
|
|
13
|
+
setFontFamily: (font: FontFamily) => Promise<void>;
|
|
14
|
+
themeMode: ThemeMode;
|
|
15
|
+
setThemeMode: (mode: ThemeMode) => void;
|
|
16
|
+
shortcuts: ShortcutDefinition[];
|
|
17
|
+
updateBinding: (id: string, binding: ShortcutBinding) => Promise<void>;
|
|
18
|
+
toggleShortcutEnabled: (id: string) => Promise<void>;
|
|
19
|
+
resetShortcutsToDefaults: () => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const LayoutContext = createContext<LayoutContextValue | null>(null);
|
|
23
|
+
|
|
24
|
+
export function useLayoutContext(): LayoutContextValue {
|
|
25
|
+
const value = use(LayoutContext);
|
|
26
|
+
if (!value) {
|
|
27
|
+
throw new Error("useLayoutContext must be used within a LayoutProvider");
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface LayoutProviderProps {
|
|
33
|
+
filePath: string;
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function LayoutProvider({ filePath, children }: LayoutProviderProps) {
|
|
38
|
+
const { isFullscreen, toggleLayoutMode } = useLayoutMode();
|
|
39
|
+
const { fontFamily, setFontFamily } = useFontPreference(filePath);
|
|
40
|
+
const { themeMode, setThemeMode } = useThemePreference();
|
|
41
|
+
const {
|
|
42
|
+
shortcuts,
|
|
43
|
+
updateBinding,
|
|
44
|
+
toggleEnabled: toggleShortcutEnabled,
|
|
45
|
+
resetToDefaults: resetShortcutsToDefaults,
|
|
46
|
+
} = useKeybindings(filePath);
|
|
47
|
+
|
|
48
|
+
const value = useMemo<LayoutContextValue>(
|
|
49
|
+
() => ({
|
|
50
|
+
isFullscreen,
|
|
51
|
+
toggleLayoutMode,
|
|
52
|
+
fontFamily,
|
|
53
|
+
setFontFamily,
|
|
54
|
+
themeMode,
|
|
55
|
+
setThemeMode,
|
|
56
|
+
shortcuts,
|
|
57
|
+
updateBinding,
|
|
58
|
+
toggleShortcutEnabled,
|
|
59
|
+
resetShortcutsToDefaults,
|
|
60
|
+
}),
|
|
61
|
+
[
|
|
62
|
+
isFullscreen,
|
|
63
|
+
toggleLayoutMode,
|
|
64
|
+
fontFamily,
|
|
65
|
+
setFontFamily,
|
|
66
|
+
themeMode,
|
|
67
|
+
setThemeMode,
|
|
68
|
+
shortcuts,
|
|
69
|
+
updateBinding,
|
|
70
|
+
toggleShortcutEnabled,
|
|
71
|
+
resetShortcutsToDefaults,
|
|
72
|
+
],
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
return <LayoutContext value={value}>{children}</LayoutContext>;
|
|
76
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type RefObject, useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Close a dropdown/popover when clicking outside or pressing Escape.
|
|
5
|
+
* Only attaches listeners when `active` is true.
|
|
6
|
+
*/
|
|
7
|
+
export function useClickOutside(
|
|
8
|
+
ref: RefObject<HTMLElement | null>,
|
|
9
|
+
onClose: () => void,
|
|
10
|
+
active: boolean,
|
|
11
|
+
): void {
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!active) return;
|
|
14
|
+
|
|
15
|
+
const handleClickOutside = (e: MouseEvent) => {
|
|
16
|
+
if (ref.current && !ref.current.contains(e.target as Node)) {
|
|
17
|
+
onClose();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const handleEscape = (e: KeyboardEvent) => {
|
|
22
|
+
if (e.key === "Escape") {
|
|
23
|
+
onClose();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
28
|
+
document.addEventListener("keydown", handleEscape);
|
|
29
|
+
|
|
30
|
+
return () => {
|
|
31
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
32
|
+
document.removeEventListener("keydown", handleEscape);
|
|
33
|
+
};
|
|
34
|
+
}, [ref, onClose, active]);
|
|
35
|
+
}
|