fix: exclude page actions from long images

This commit is contained in:
john
2026-07-27 21:21:54 +08:00
parent d1be5d9e2a
commit 5ae166fc44
3 changed files with 28 additions and 1 deletions
+8
View File
@@ -7,6 +7,13 @@ import { pathToFileURL } from 'node:url';
const DEFAULT_VIEWPORT_WIDTH = 1280;
const DEFAULT_VIEWPORT_HEIGHT = 720;
const MAX_LONG_IMAGE_HEIGHT = 20000;
export const LONG_IMAGE_EXPORT_STYLE = `
[data-mindspace-public-share],
.publication-share-fab,
.publication-share-sheet {
display: none !important;
}
`;
export function isLongImageDownloadRequest(query) {
const value = String(query?.download ?? query?.export ?? '').trim().toLowerCase();
@@ -84,6 +91,7 @@ export async function renderLongImage({
type: 'png',
animations: 'disabled',
caret: 'hide',
style: LONG_IMAGE_EXPORT_STYLE,
});
return {
outputPath: destination,
+19
View File
@@ -0,0 +1,19 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import {
isLongImageDownloadRequest,
LONG_IMAGE_EXPORT_STYLE,
} from './mindspace-long-image.mjs';
test('recognizes supported long-image download query values', () => {
assert.equal(isLongImageDownloadRequest({ download: 'long-image' }), true);
assert.equal(isLongImageDownloadRequest({ export: 'png' }), true);
assert.equal(isLongImageDownloadRequest({ download: 'document' }), false);
});
test('long-image capture style hides platform page actions', () => {
assert.match(LONG_IMAGE_EXPORT_STYLE, /\[data-mindspace-public-share\]/);
assert.match(LONG_IMAGE_EXPORT_STYLE, /\.publication-share-fab/);
assert.match(LONG_IMAGE_EXPORT_STYLE, /\.publication-share-sheet/);
assert.match(LONG_IMAGE_EXPORT_STYLE, /display:\s*none\s*!important/);
});
+1 -1
View File
File diff suppressed because one or more lines are too long