Add PDF search feature to pdf-server (#445)

* Add PDF search feature to pdf-server

Adds full-text search functionality to the PDF viewer:

- Search button in toolbar (Ctrl/Cmd+F to open)
- Search bar with input, prev/next navigation, match count
- Text extraction and caching across all pages
- Highlight overlays using DOM Range API
- Case-insensitive search across entire document
- Keyboard shortcuts: Ctrl+F (open), Enter (next), Shift+Enter (prev), Escape (close)

Changes:
- mcp-app.html: Add search button, search bar, highlight layer
- src/mcp-app.css: Add search/highlight styles and PDF.js text layer rules
- src/mcp-app.ts: Add search state, functions, event listeners

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* update screenshots

* Add fullscreen button to threejs-server

* Fix prettier formatting

* Move search bar below toolbar, right-aligned

* Make search bar compact and right-aligned

* Float search bar over page content

* Ctrl/Cmd+F toggles search; pass through to browser when empty

* Hide search nav controls until query is entered

* Skip scroll when search highlight is already visible

* Fix search bar right-edge alignment with container border

* Prevent browser find when our search is open with text

* Cmd+F when search input is focused passes through to browser find

* Fix prettier formatting in README

* Remove unrelated formatting and threejs changes from PR

* prettier

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Olivier Chafik 2026-02-19 10:56:40 -08:00 • committed by GitHub
commit 8cad9f04c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,7 +11,11 @@
<div id="loading" class="loading">
<div class="spinner"></div>
<p id="loading-text">Loading PDF...</p>
<div id="progress-container" class="progress-container" style="display: none">
<div
id="progress-container"
class="progress-container"
style="display: none"
>
<div id="progress-bar" class="progress-bar"></div>
</div>
<p id="progress-text" class="progress-text"></p>
@ -57,16 +61,58 @@
<button id="zoom-in-btn" class="zoom-btn" title="Zoom in (+)">
+
</button>
<button id="fullscreen-btn" class="fullscreen-btn" title="Toggle fullscreen">
<button
id="search-btn"
class="search-btn"
title="Search (Ctrl+F)"
></button>
<button
id="fullscreen-btn"
class="fullscreen-btn"
title="Toggle fullscreen"
>
⛶
</button>
</div>
</div>
<!-- Search bar below toolbar, right-aligned -->
<div id="search-bar" class="search-bar" style="display: none">
<input
id="search-input"
class="search-input"
type="text"
placeholder="Search..."
autocomplete="off"
/>
<span id="search-match-count" class="search-match-count"></span>
<button
id="search-prev-btn"
class="search-nav-btn"
title="Previous (Shift+Enter)"
>
&#x25B2;
</button>
<button
id="search-next-btn"
class="search-nav-btn"
title="Next (Enter)"
>
&#x25BC;
</button>
<button
id="search-close-btn"
class="search-nav-btn"
title="Close (Esc)"
>
&#x2715;
</button>
</div>
<!-- Single Page Canvas Container -->
<div class="canvas-container">
<div class="page-wrapper">
<canvas id="pdf-canvas"></canvas>
<div id="highlight-layer" class="highlight-layer"></div>
<div id="text-layer" class="text-layer"></div>
</div>
</div>