Spaces:
Sleeping
Paste editor: cap height + fit bases/line to the box (not a fixed 10)
Browse filesA 10-base/line wrap turned a 1,128-nt gene into 113 lines, and the editor had
no height cap — the tall line-numbered gutter stretched the whole .paste-shell
down the page and shoved the form ~2,700px below the fold. Two fixes (both
editors — directed-evolution #pasteArea and CRISPR #crisprInput, shared code):
- Cap .paste-shell at max-height:340px (it already had overflow:hidden +
synced gutter/textarea scroll) and disable textarea resize. A long
sequence now scrolls INSIDE a compact box; the form stays right below it.
- _fitBasesPerLine(): wrap to a whole number of 10-base blocks that fit the
box's measured width, clamped [10,60]. Desktop ~50–60/line (1,128 nt → 19
lines), phone ~20/line (no horizontal scroll). Gutter still numbers by
base position; the step just follows the line width (1·61·121 desktop,
1·21·41 mobile). Debounced resize re-fits on width change.
Cache-buster -> v=20260602-fit. 112 tests pass. Verified at 1280px (60/line,
capped 340px box) and 375px (20/line, no h-scroll) on both editors.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- dee/static/app.css +9 -0
- dee/static/app.js +50 -10
- dee/static/index.html +2 -2
|
@@ -785,6 +785,11 @@ input:focus, textarea:focus, select:focus {
|
|
| 785 |
border-radius: var(--r-2);
|
| 786 |
background: var(--gray-0);
|
| 787 |
overflow: hidden;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 788 |
transition: all var(--t-fast) var(--ease);
|
| 789 |
box-shadow: var(--elev-1);
|
| 790 |
}
|
|
@@ -824,6 +829,10 @@ input:focus, textarea:focus, select:focus {
|
|
| 824 |
box-shadow: none !important;
|
| 825 |
overflow: auto;
|
| 826 |
white-space: pre;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 827 |
}
|
| 828 |
|
| 829 |
.paste-actions {
|
|
|
|
| 785 |
border-radius: var(--r-2);
|
| 786 |
background: var(--gray-0);
|
| 787 |
overflow: hidden;
|
| 788 |
+
/* Cap the editor height so a long sequence (e.g. a 1,128-nt CDS) scrolls
|
| 789 |
+
INSIDE the box instead of stretching it down the page. The gutter +
|
| 790 |
+
textarea scroll in sync (overflow:hidden gutter + overflow:auto
|
| 791 |
+
textarea, scrollTop mirrored in JS). */
|
| 792 |
+
max-height: 340px;
|
| 793 |
transition: all var(--t-fast) var(--ease);
|
| 794 |
box-shadow: var(--elev-1);
|
| 795 |
}
|
|
|
|
| 829 |
box-shadow: none !important;
|
| 830 |
overflow: auto;
|
| 831 |
white-space: pre;
|
| 832 |
+
/* The shell owns the height now (max-height + scroll); a user-drag resize
|
| 833 |
+
would desync the gutter, so disable it. */
|
| 834 |
+
resize: none;
|
| 835 |
+
min-height: 0;
|
| 836 |
}
|
| 837 |
|
| 838 |
.paste-actions {
|
|
@@ -155,13 +155,13 @@ const pasteStats = $('#pasteStats');
|
|
| 155 |
|
| 156 |
// ── Base-ruler layout shared by both sequence paste editors (directed-
|
| 157 |
// evolution #pasteArea and CRISPR #crisprInput). The sequence is wrapped to
|
| 158 |
-
//
|
| 159 |
-
//
|
| 160 |
-
//
|
| 161 |
-
//
|
| 162 |
-
//
|
| 163 |
-
//
|
| 164 |
-
const BASES_PER_LINE = 10;
|
| 165 |
const SEQ_REWRAP_CAP = 30000;
|
| 166 |
|
| 167 |
function _seqLayout(raw, width) {
|
|
@@ -226,11 +226,41 @@ function _paintSeqGutter(gutterEl, starts) {
|
|
| 226 |
gutterEl.innerHTML = '';
|
| 227 |
gutterEl.appendChild(frag);
|
| 228 |
}
|
| 229 |
-
//
|
| 230 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
function reflowSeqEditor(ta, gutterEl) {
|
| 232 |
const raw = ta.value;
|
| 233 |
-
const width = raw.length > SEQ_REWRAP_CAP ? 60 :
|
| 234 |
const { text, starts } = _seqLayout(raw, width);
|
| 235 |
if (text !== raw) {
|
| 236 |
const sig = _seqSig(raw, ta.selectionStart);
|
|
@@ -253,6 +283,11 @@ pasteArea.addEventListener('input', renderGutter);
|
|
| 253 |
pasteArea.addEventListener('scroll', () => {
|
| 254 |
pasteGutter.scrollTop = pasteArea.scrollTop;
|
| 255 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
renderGutter();
|
| 257 |
|
| 258 |
// ====================================================== HASH-BASED ROUTING
|
|
@@ -3844,6 +3879,11 @@ if (_quitBtn) {
|
|
| 3844 |
ta.addEventListener('scroll', () => {
|
| 3845 |
crisprGutter.scrollTop = ta.scrollTop;
|
| 3846 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3847 |
renderCrisprGutter();
|
| 3848 |
}
|
| 3849 |
|
|
|
|
| 155 |
|
| 156 |
// ── Base-ruler layout shared by both sequence paste editors (directed-
|
| 157 |
// evolution #pasteArea and CRISPR #crisprInput). The sequence is wrapped to
|
| 158 |
+
// a whole number of 10-base blocks that fit the box (_fitBasesPerLine), and
|
| 159 |
+
// the gutter is numbered by base POSITION (1, 21, 41 … — step = line width)
|
| 160 |
+
// instead of line index, so it reads as a real nucleotide ruler that adapts
|
| 161 |
+
// to the screen. FASTA headers (>) are kept verbatim, take no base number,
|
| 162 |
+
// and reset the counter (per-record numbering). Above SEQ_REWRAP_CAP chars
|
| 163 |
+
// we force a 60-wide wrap so a giant paste can't spawn 100k gutter nodes.
|
| 164 |
+
const BASES_PER_LINE = 10; // fallback/min line width (used when the box isn't measurable)
|
| 165 |
const SEQ_REWRAP_CAP = 30000;
|
| 166 |
|
| 167 |
function _seqLayout(raw, width) {
|
|
|
|
| 226 |
gutterEl.innerHTML = '';
|
| 227 |
gutterEl.appendChild(frag);
|
| 228 |
}
|
| 229 |
+
// Measure the editor's monospace character width once (cached probe) so we can
|
| 230 |
+
// fit the line to the box.
|
| 231 |
+
let _charProbe = null;
|
| 232 |
+
function _monoCharWidth(font) {
|
| 233 |
+
if (!_charProbe) {
|
| 234 |
+
_charProbe = document.createElement('span');
|
| 235 |
+
_charProbe.setAttribute('aria-hidden', 'true');
|
| 236 |
+
_charProbe.style.cssText = 'position:absolute;left:-9999px;top:0;visibility:hidden;white-space:pre;padding:0;border:0;margin:0';
|
| 237 |
+
document.body.appendChild(_charProbe);
|
| 238 |
+
}
|
| 239 |
+
_charProbe.style.font = font;
|
| 240 |
+
_charProbe.textContent = 'ACGT'.repeat(25); // 100 chars
|
| 241 |
+
const w = _charProbe.getBoundingClientRect().width / 100;
|
| 242 |
+
return w > 0 ? w : 0;
|
| 243 |
+
}
|
| 244 |
+
// How many bases fit on one line of THIS textarea, rounded down to a whole
|
| 245 |
+
// block of 10 and clamped to [10, 60]. Adapts to the device: a wide desktop
|
| 246 |
+
// box gets ~50–60/line, a phone ~20–30/line — so the sequence is never more
|
| 247 |
+
// than ~viewport-wide (no horizontal scroll) and a long gene isn't hundreds of
|
| 248 |
+
// 10-char lines. Falls back to BASES_PER_LINE when the box isn't laid out yet
|
| 249 |
+
// (hidden tab) — a later input/resize re-fits it.
|
| 250 |
+
function _fitBasesPerLine(ta) {
|
| 251 |
+
const cs = getComputedStyle(ta);
|
| 252 |
+
const avail = ta.clientWidth - (parseFloat(cs.paddingLeft) || 0) - (parseFloat(cs.paddingRight) || 0);
|
| 253 |
+
if (!(avail > 0)) return BASES_PER_LINE;
|
| 254 |
+
const cw = _monoCharWidth(cs.font || `${cs.fontSize} ${cs.fontFamily}`);
|
| 255 |
+
if (!(cw > 0)) return BASES_PER_LINE;
|
| 256 |
+
const fit = Math.floor((avail - cw) / cw); // -1 char safety margin
|
| 257 |
+
return Math.max(10, Math.min(60, Math.floor(fit / 10) * 10));
|
| 258 |
+
}
|
| 259 |
+
// Reflow a sequence textarea in place + repaint its gutter as a base ruler.
|
| 260 |
+
// Line width adapts to the box (multiple of 10). Returns the base count.
|
| 261 |
function reflowSeqEditor(ta, gutterEl) {
|
| 262 |
const raw = ta.value;
|
| 263 |
+
const width = raw.length > SEQ_REWRAP_CAP ? 60 : _fitBasesPerLine(ta);
|
| 264 |
const { text, starts } = _seqLayout(raw, width);
|
| 265 |
if (text !== raw) {
|
| 266 |
const sig = _seqSig(raw, ta.selectionStart);
|
|
|
|
| 283 |
pasteArea.addEventListener('scroll', () => {
|
| 284 |
pasteGutter.scrollTop = pasteArea.scrollTop;
|
| 285 |
});
|
| 286 |
+
let _deGutterResizeT;
|
| 287 |
+
window.addEventListener('resize', () => {
|
| 288 |
+
clearTimeout(_deGutterResizeT);
|
| 289 |
+
_deGutterResizeT = setTimeout(renderGutter, 150); // re-fit line width to the new box width
|
| 290 |
+
});
|
| 291 |
renderGutter();
|
| 292 |
|
| 293 |
// ====================================================== HASH-BASED ROUTING
|
|
|
|
| 3879 |
ta.addEventListener('scroll', () => {
|
| 3880 |
crisprGutter.scrollTop = ta.scrollTop;
|
| 3881 |
});
|
| 3882 |
+
let _crGutterResizeT;
|
| 3883 |
+
window.addEventListener('resize', () => {
|
| 3884 |
+
clearTimeout(_crGutterResizeT);
|
| 3885 |
+
_crGutterResizeT = setTimeout(renderCrisprGutter, 150); // re-fit on width change
|
| 3886 |
+
});
|
| 3887 |
renderCrisprGutter();
|
| 3888 |
}
|
| 3889 |
|
|
@@ -22,7 +22,7 @@
|
|
| 22 |
<!-- ?v= query bumps invalidate browser + iframe asset caches when app.css /
|
| 23 |
app.js change. Bump these numbers whenever you ship a frontend update —
|
| 24 |
without them, users keep getting the stale file for up to a week. -->
|
| 25 |
-
<link rel="stylesheet" href="/static/app.css?v=20260602-
|
| 26 |
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg?v=2" />
|
| 27 |
<link rel="apple-touch-icon" href="/static/favicon.svg?v=2" />
|
| 28 |
<!-- Mol* (PDBe) viewer for AlphaFold structure embed. Loaded async; the
|
|
@@ -1176,6 +1176,6 @@
|
|
| 1176 |
<!-- Cloning reference data must load before app.js so the Designer
|
| 1177 |
can read VECTORS / ENZYMES / CLONING_METHODS / TAGS / LINKERS. -->
|
| 1178 |
<script src="/static/cloning_db.js?v=20260530-ui-polish" defer></script>
|
| 1179 |
-
<script src="/static/app.js?v=20260602-
|
| 1180 |
</body>
|
| 1181 |
</html>
|
|
|
|
| 22 |
<!-- ?v= query bumps invalidate browser + iframe asset caches when app.css /
|
| 23 |
app.js change. Bump these numbers whenever you ship a frontend update —
|
| 24 |
without them, users keep getting the stale file for up to a week. -->
|
| 25 |
+
<link rel="stylesheet" href="/static/app.css?v=20260602-fit" />
|
| 26 |
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg?v=2" />
|
| 27 |
<link rel="apple-touch-icon" href="/static/favicon.svg?v=2" />
|
| 28 |
<!-- Mol* (PDBe) viewer for AlphaFold structure embed. Loaded async; the
|
|
|
|
| 1176 |
<!-- Cloning reference data must load before app.js so the Designer
|
| 1177 |
can read VECTORS / ENZYMES / CLONING_METHODS / TAGS / LINKERS. -->
|
| 1178 |
<script src="/static/cloning_db.js?v=20260530-ui-polish" defer></script>
|
| 1179 |
+
<script src="/static/app.js?v=20260602-fit" defer></script>
|
| 1180 |
</body>
|
| 1181 |
</html>
|