ep_images_extended 1.0.51 → 1.0.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ep.json +4 -0
- package/index.js +8 -2
- package/package.json +1 -1
- package/static/js/clientHooks.js +25 -3
package/ep.json
CHANGED
package/index.js
CHANGED
|
@@ -8,7 +8,6 @@ const url = require('url');
|
|
|
8
8
|
const fs = require('fs');
|
|
9
9
|
const fsp = fs.promises;
|
|
10
10
|
const { JSDOM } = require('jsdom');
|
|
11
|
-
const log4js = require('log4js');
|
|
12
11
|
const { exec } = require('child_process');
|
|
13
12
|
const util = require('util');
|
|
14
13
|
const execPromise = util.promisify(exec);
|
|
@@ -23,7 +22,14 @@ try {
|
|
|
23
22
|
console.warn('[ep_images_extended] AWS SDK not installed; s3_presigned storage will not work.');
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
// Replaced log4js with lightweight console wrapper to avoid external dependency
|
|
26
|
+
// while preserving same API surface used below.
|
|
27
|
+
const logger = {
|
|
28
|
+
debug: console.debug.bind(console),
|
|
29
|
+
info: console.info.bind(console),
|
|
30
|
+
warn: console.warn.bind(console),
|
|
31
|
+
error: console.error.bind(console),
|
|
32
|
+
};
|
|
27
33
|
|
|
28
34
|
// Simple in-memory IP rate limiter
|
|
29
35
|
const _presignRateStore = new Map();
|
package/package.json
CHANGED
package/static/js/clientHooks.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// Modified from ep_image_insert 1.0.7
|
|
3
3
|
|
|
4
|
+
// Optional helper (shared with ep_docx_html_customizer) that provides a CORS fetch with
|
|
5
|
+
// automatic same-origin proxy fallback. If the plugin is not present we simply fall back
|
|
6
|
+
// to the native fetch logic.
|
|
7
|
+
let fetchWithCorsProxy;
|
|
8
|
+
try {
|
|
9
|
+
({fetchWithCorsProxy} = require('../../../ep_docx_html_customizer/transform_common'));
|
|
10
|
+
} catch (_) { /* helper not available – fallback to plain fetch */ }
|
|
11
|
+
|
|
12
|
+
if (!fetchWithCorsProxy && typeof window !== 'undefined') {
|
|
13
|
+
fetchWithCorsProxy = window.fetchWithCorsProxy;
|
|
14
|
+
}
|
|
15
|
+
|
|
4
16
|
// Simple UUID generator
|
|
5
17
|
function generateUUID() {
|
|
6
18
|
return 'xxxx-xxxx-4xxx-yxxx-xxxx'.replace(/[xy]/g, function(c) {
|
|
@@ -1146,9 +1158,19 @@ exports.postAceInit = function (hook, context) {
|
|
|
1146
1158
|
// For HTTP URLs, fetch and convert to PNG
|
|
1147
1159
|
else if (imageSrc.startsWith('http')) {
|
|
1148
1160
|
// First try to fetch the image
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1161
|
+
let response;
|
|
1162
|
+
try {
|
|
1163
|
+
if (typeof fetchWithCorsProxy === 'function') {
|
|
1164
|
+
response = await fetchWithCorsProxy(imageSrc);
|
|
1165
|
+
} else {
|
|
1166
|
+
response = await fetch(imageSrc, {mode: 'cors'});
|
|
1167
|
+
if (!response.ok) throw new Error(`status ${response.status}`);
|
|
1168
|
+
}
|
|
1169
|
+
} catch (fetchErr) {
|
|
1170
|
+
// Remote fetch failed – fall back to copying the URL as plain text
|
|
1171
|
+
await navigator.clipboard.writeText(imageSrc);
|
|
1172
|
+
showCopyFeedback(shouldCut ? 'Image URL cut to clipboard (fallback)' : 'Image URL copied to clipboard (fallback)');
|
|
1173
|
+
return; // Abort PNG-blob path
|
|
1152
1174
|
}
|
|
1153
1175
|
|
|
1154
1176
|
// Convert the fetched image to a data URL, then to PNG
|