postgis.git / summary / log / commit / refs

commit    166befe577902dfb35bc6ac8ea4f6ce8600a947e
Author:   Darafei Praliaskouski <me@komzpa.net>
Date:     Sun Jul 12 18:22:54 2026 +0000

    docs: move wrap markers into line gutter


doc/html/example-blocks.js | 18 ++++++++++++++++-- doc/html/style.css | 20 +++++++++++++++----- doc/html/test_example_blocks.js | 26 ++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/doc/html/example-blocks.js b/doc/html/example-blocks.js index 434c96ae2..b91f7c7fc 100644 --- a/doc/html/example-blocks.js +++ b/doc/html/example-blocks.js @@ -458,10 +458,22 @@ function updateWrapIndicators() { var lines = document.querySelectorAll('.postgis-example-block pre[data-postgis-lines="true"] > .line'); for (var i = 0; i < lines.length; i += 1) { + var oldIndicators = lines[i].querySelectorAll(':scope > .postgis-wrap-indicator'); + for (var oldIndex = 0; oldIndex < oldIndicators.length; oldIndex += 1) { + oldIndicators[oldIndex].remove(); + } var style = window.getComputedStyle(lines[i]); var lineHeight = parseFloat(style.lineHeight); - var wrapped = lineHeight > 0 && lines[i].scrollHeight > lineHeight * 1.5; + var visualLineCount = lineHeight > 0 ? Math.max(1, Math.round(lines[i].scrollHeight / lineHeight)) : 1; + var wrapped = visualLineCount > 1; lines[i].classList.toggle('line-wrapped', wrapped); + for (var visualLine = 1; visualLine < visualLineCount; visualLine += 1) { + var indicator = document.createElement('span'); + indicator.className = 'postgis-wrap-indicator'; + indicator.setAttribute('aria-hidden', 'true'); + indicator.style.top = (visualLine * lineHeight) + 'px'; + lines[i].appendChild(indicator); + } } } @@ -814,7 +826,9 @@ return originalBlockText.get(pre); } var clone = pre.cloneNode(true); - var ignored = clone.querySelectorAll('.linenumber, .line-number, .ln, .co, .callout, .callout-bug'); + var ignored = clone.querySelectorAll( + '.linenumber, .line-number, .ln, .co, .callout, .callout-bug, .postgis-wrap-indicator' + ); for (var i = 0; i < ignored.length; i += 1) { ignored[i].remove(); } diff --git a/doc/html/style.css b/doc/html/style.css index 7bf7a7e58..166d2f80e 100644 --- a/doc/html/style.css +++ b/doc/html/style.css @@ -248,15 +248,25 @@ pre, width: 2.55em; } -.postgis-example-block pre > .line.line-wrapped::after { +.postgis-example-block pre > .line > .postgis-wrap-indicator { color: #71808f; - content: "\21AA"; - font-size: 0.72em; + font-size: 0.78em; + height: 1.45em; + left: 0; + line-height: 1; opacity: 0.8; + padding-right: 0.8em; + padding-top: 0.15em; + pointer-events: none; position: absolute; - right: 0.35em; - top: 0.2em; + text-align: right; + text-indent: 0; user-select: none; + width: 2.55em; +} + +.postgis-example-block pre > .line > .postgis-wrap-indicator::before { + content: "\21AA"; } .postgis-example-code:has(+ .postgis-example-output) { diff --git a/doc/html/test_example_blocks.js b/doc/html/test_example_blocks.js index 3993b4c6a..3abe98877 100644 --- a/doc/html/test_example_blocks.js +++ b/doc/html/test_example_blocks.js @@ -57,6 +57,7 @@ function makeLiteralTree(text, document) { attributes: {}, className: '', id: '', + style: {}, get textContent() { return this.children.map((child) => child.nodeValue === undefined ? child.textContent : child.nodeValue) .join(''); @@ -68,6 +69,9 @@ function makeLiteralTree(text, document) { removeFromParent(node); this.children.push(node); node.parentNode = this; + }, + remove() { + removeFromParent(this); } }; } @@ -135,6 +139,17 @@ async function main() { return { owner: index === 0 ? output : blocks[0], scrollHeight: 16, + children: [], + appendChild(node) { + this.children.push(node); + node.parentNode = this; + }, + querySelectorAll(selector) { + if (selector === ':scope > .postgis-wrap-indicator') { + return this.children.filter((child) => child.className === 'postgis-wrap-indicator'); + } + return []; + }, classList: { toggle(name, enabled) { if (enabled) { @@ -334,6 +349,17 @@ async function main() { resizeObserverCallback([{ target: output }]); assert.strictEqual(layoutLines[0].owner, output); assert(wrapClasses[0].has('line-wrapped')); + assert.strictEqual(layoutLines[0].children.length, 1); + assert.strictEqual(layoutLines[0].children[0].attributes['aria-hidden'], 'true'); + assert.strictEqual(layoutLines[0].children[0].style.top, '16px'); + layoutLines[0].scrollHeight = 48; + resizeObserverCallback([{ target: output }]); + assert.strictEqual(layoutLines[0].children.length, 2); + assert.deepStrictEqual(layoutLines[0].children.map((indicator) => indicator.style.top), ['16px', '32px']); + layoutLines[0].scrollHeight = 16; + resizeObserverCallback([{ target: output }]); + assert(!wrapClasses[0].has('line-wrapped')); + assert.strictEqual(layoutLines[0].children.length, 0); const pairIds = Array.from(blocks[3].innerHTML.matchAll(/data-postgis-paren-pair="(\d+)"/g), (match) => match[1]); [parent: 03b61b129a65]