diff --git a/dev/tool/src/index.ts b/dev/tool/src/index.ts index b4369e4a20..e2ae3c88d1 100644 --- a/dev/tool/src/index.ts +++ b/dev/tool/src/index.ts @@ -1139,7 +1139,8 @@ export function devTool ( .option('-m, --move ', 'When set to true, the files will be moved, otherwise copied', 'false') .option('-bl, --blobLimit ', 'A blob size limit in megabytes (default 50mb)', '50') .option('-c, --concurrency ', 'Number of files being processed concurrently', '10') - .action(async (cmd: { workspace: string, move: string, blobLimit: string, concurrency: string }) => { + .option('--disabled', 'Include disabled workspaces', false) + .action(async (cmd: { workspace: string, move: string, blobLimit: string, concurrency: string, disabled: boolean }) => { const params = { blobSizeLimitMb: parseInt(cmd.blobLimit), concurrency: parseInt(cmd.concurrency), @@ -1165,6 +1166,10 @@ export function devTool ( if (cmd.workspace !== '' && workspace.workspace !== cmd.workspace) { continue } + if (workspace.disabled === true && !cmd.disabled) { + console.log('ignore disabled workspace', workspace.workspace) + continue + } console.log('start', workspace.workspace, index, '/', workspaces.length) await moveFiles(toolCtx, getWorkspaceId(workspace.workspace), exAdapter, params) @@ -1182,7 +1187,8 @@ export function devTool ( program .command('sync-files') .option('-w, --workspace ', 'Selected workspace only', '') - .action(async (cmd: { workspace: string }) => { + .option('--disabled', 'Include disabled workspaces', false) + .action(async (cmd: { workspace: string, disabled: boolean }) => { const { mongodbUri } = prepareTools() await withDatabase(mongodbUri, async (db) => { await withStorage(mongodbUri, async (adapter) => { @@ -1196,13 +1202,22 @@ export function devTool ( workspaces.sort((a, b) => b.lastVisit - a.lastVisit) for (const workspace of workspaces) { + if (workspace.disabled === true && !cmd.disabled) { + console.log('ignore disabled workspace', workspace.workspace) + continue + } + if (cmd.workspace !== '' && workspace.workspace !== cmd.workspace) { continue } - console.log('start', workspace.workspace, index, '/', workspaces.length) - await syncFiles(toolCtx, getWorkspaceId(workspace.workspace), exAdapter) - console.log('done', workspace.workspace) + try { + console.log('start', workspace.workspace, index, '/', workspaces.length) + await syncFiles(toolCtx, getWorkspaceId(workspace.workspace), exAdapter) + console.log('done', workspace.workspace) + } catch (err) { + console.warn('failed to sync files', err) + } index += 1 } diff --git a/plugins/attachment-resources/src/components/AttachmentAction.svelte b/plugins/attachment-resources/src/components/AttachmentAction.svelte new file mode 100644 index 0000000000..5ca696292a --- /dev/null +++ b/plugins/attachment-resources/src/components/AttachmentAction.svelte @@ -0,0 +1,45 @@ + + + + diff --git a/plugins/attachment-resources/src/components/AttachmentActions.svelte b/plugins/attachment-resources/src/components/AttachmentActions.svelte index 744fe2ccd2..9072bf146e 100644 --- a/plugins/attachment-resources/src/components/AttachmentActions.svelte +++ b/plugins/attachment-resources/src/components/AttachmentActions.svelte @@ -14,29 +14,21 @@ --> diff --git a/plugins/attachment-resources/src/components/AttachmentImagePreview.svelte b/plugins/attachment-resources/src/components/AttachmentImagePreview.svelte index 78bbd44336..611003711b 100644 --- a/plugins/attachment-resources/src/components/AttachmentImagePreview.svelte +++ b/plugins/attachment-resources/src/components/AttachmentImagePreview.svelte @@ -26,6 +26,7 @@ interface Dimensions { width: 'auto' | number height: 'auto' | number + fit: 'cover' | 'contain' } const minSizeRem = 4 @@ -45,7 +46,8 @@ if (size === 'auto') { return { width: 'auto', - height: 'auto' + height: 'auto', + fit: 'contain' } } @@ -55,42 +57,41 @@ if (!metadata) { return { width: preferredWidth, - height: preferredWidth + height: preferredWidth, + fit: 'contain' } } const { originalWidth, originalHeight } = metadata - const maxSize = maxSizeRem * parseFloat(getComputedStyle(document.documentElement).fontSize) + const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize) + const maxSize = maxSizeRem * fontSize + const minSize = minSizeRem * fontSize const width = Math.min(originalWidth, preferredWidth) const ratio = originalHeight / originalWidth const height = width * ratio + const fit = width < minSize || height < minSize ? 'cover' : 'contain' + if (height > maxSize) { return { width: maxSize / ratio, - height: maxSize + height: maxSize, + fit + } + } else if (height < minSize) { + return { + width, + height: minSize, + fit + } + } else { + return { + width, + height, + fit } } - - return { - width, - height - } - } - - function getObjectFit (size: Dimensions): 'contain' | 'cover' { - if (size.width === 'auto' || size.height === 'auto') { - return 'contain' - } - - const minSize = minSizeRem * parseFloat(getComputedStyle(document.documentElement).fontSize) - - if (size.width < minSize || size.height < minSize) { - return 'cover' - } - - return 'contain' } function getUrlSize (size: AttachmentImageSize): IconSize { @@ -110,9 +111,9 @@ {#await getBlobRef(value.file, value.name, sizeToWidth(urlSize)) then blobSrc} {value.name} @@ -124,7 +125,6 @@ max-width: 20rem; max-height: 20rem; border-radius: 0.75rem; - object-fit: contain; min-height: 4rem; min-width: 4rem; } diff --git a/plugins/attachment-resources/src/components/AttachmentPreview.svelte b/plugins/attachment-resources/src/components/AttachmentPreview.svelte index 7a1ecea86f..c190389330 100644 --- a/plugins/attachment-resources/src/components/AttachmentPreview.svelte +++ b/plugins/attachment-resources/src/components/AttachmentPreview.svelte @@ -1,6 +1,6 @@ -
- {#if editor && visible && visibleActions.length > 0} -
+