From 9e5e8b020a95333f55ab729be36e334b20fde489 Mon Sep 17 00:00:00 2001 From: Alexey Koshelev Date: Wed, 9 Apr 2025 19:03:55 +0300 Subject: [PATCH] [AI] Fix styles for custom providers window --- sdkjs-plugins/content/ai/customProviders.html | 1 + .../ai/resources/styles/customProviders.css | 1 + .../content/ai/scripts/customProviders.js | 30 +++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/sdkjs-plugins/content/ai/customProviders.html b/sdkjs-plugins/content/ai/customProviders.html index 282394a4..3b11e36e 100644 --- a/sdkjs-plugins/content/ai/customProviders.html +++ b/sdkjs-plugins/content/ai/customProviders.html @@ -24,6 +24,7 @@ + diff --git a/sdkjs-plugins/content/ai/resources/styles/customProviders.css b/sdkjs-plugins/content/ai/resources/styles/customProviders.css index eb00d610..7b86b6bf 100644 --- a/sdkjs-plugins/content/ai/resources/styles/customProviders.css +++ b/sdkjs-plugins/content/ai/resources/styles/customProviders.css @@ -52,6 +52,7 @@ body { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; + border: none; } #buttons-block { diff --git a/sdkjs-plugins/content/ai/scripts/customProviders.js b/sdkjs-plugins/content/ai/scripts/customProviders.js index c812af7d..ce20ade7 100644 --- a/sdkjs-plugins/content/ai/scripts/customProviders.js +++ b/sdkjs-plugins/content/ai/scripts/customProviders.js @@ -132,6 +132,10 @@ window.Asc.plugin.onTranslate = function () { }); }; +window.addEventListener("resize", onResize); +onResize(); + + function handlerChangeFileInput(files) { let pendingFiles = files.length; let hasError = false; @@ -203,4 +207,30 @@ function onThemeChanged(theme) { let newSrc = src.replace(/(icons\/)([^\/]+)(\/)/, '$1' + themeType + '$3'); icon.setAttribute('src', newSrc); } +} + +function getZoomSuffixForImage() { + var ratio = Math.round(window.devicePixelRatio / 0.25) * 0.25; + ratio = Math.max(ratio, 1); + ratio = Math.min(ratio, 2); + if(ratio == 1) return '' + else { + return '@' + ratio + 'x'; + } +} + +function onResize () { + $('img').each(function() { + var el = $(this); + var src = $(el).attr('src'); + if(!src.includes('resources/icons/')) return; + + var srcParts = src.split('/'); + var fileNameWithRatio = srcParts.pop(); + var clearFileName = fileNameWithRatio.replace(/@\d+(\.\d+)?x/, ''); + var newFileName = clearFileName; + newFileName = clearFileName.replace(/(\.[^/.]+)$/, getZoomSuffixForImage() + '$1'); + srcParts.push(newFileName); + el.attr('src', srcParts.join('/')); + }); } \ No newline at end of file