fix: exclude page actions from long images
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user