ep_images_extended 1.0.62 → 1.1.1
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/index.js +6 -1
- package/package.json +1 -1
- package/settings.js +15 -3
- package/static/js/clientHooks.js +8 -6
package/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// Modified from ep_image_insert 1.0.7
|
|
3
3
|
const eejs = require('ep_etherpad-lite/node/eejs/');
|
|
4
|
-
|
|
4
|
+
// Compat: Etherpad 2.4 uses ESM for Settings. Support both CJS and ESM.
|
|
5
|
+
const settingsModule = require('ep_etherpad-lite/node/utils/Settings');
|
|
6
|
+
const settings = settingsModule.default || settingsModule;
|
|
5
7
|
const { randomUUID } = require('crypto');
|
|
6
8
|
const path = require('path');
|
|
7
9
|
const url = require('url');
|
|
@@ -184,6 +186,9 @@ exports.expressConfigure = (hookName, context) => {
|
|
|
184
186
|
|
|
185
187
|
// ADD LOCAL DISK STORAGE UPLOAD ENDPOINT ------------------------------
|
|
186
188
|
// Register the route only if storage.type === 'local'
|
|
189
|
+
logger.info('[ep_images_extended] storageType at startup:',
|
|
190
|
+
settings.ep_images_extended?.storage?.type);
|
|
191
|
+
|
|
187
192
|
if (settings.ep_images_extended && settings.ep_images_extended.storage && settings.ep_images_extended.storage.type === 'local') {
|
|
188
193
|
// Route: POST /p/:padId/pluginfw/ep_images_extended/upload
|
|
189
194
|
// Accepts multipart/form-data with field "file" and saves it to the
|
package/package.json
CHANGED
package/settings.js
CHANGED
|
@@ -2,12 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
exports.loadSettings = (hookName,
|
|
6
|
-
|
|
5
|
+
exports.loadSettings = (hookName, args, cb) => {
|
|
6
|
+
// Sync ep_images_extended config into the runtime Settings singleton that other
|
|
7
|
+
// parts of this plugin import, to avoid workspace/symlink doubletons.
|
|
8
|
+
try {
|
|
9
|
+
const settingsModule = require('ep_etherpad-lite/node/utils/Settings');
|
|
10
|
+
const runtimeSettings = settingsModule.default || settingsModule;
|
|
11
|
+
if (args && args.settings && args.settings.ep_images_extended) {
|
|
12
|
+
runtimeSettings.ep_images_extended = args.settings.ep_images_extended;
|
|
13
|
+
}
|
|
14
|
+
} catch (e) {
|
|
15
|
+
console.warn('[ep_images_extended] Failed to sync settings:', e);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!args.settings || !args.settings.socketIo) {
|
|
7
19
|
console.warn('Please update Etherpad to >=1.8.8');
|
|
8
20
|
} else {
|
|
9
21
|
// Setting maxHttpBufferSize to 10 MiB :)
|
|
10
|
-
|
|
22
|
+
args.settings.socketIo.maxHttpBufferSize = 100000000;
|
|
11
23
|
}
|
|
12
24
|
cb();
|
|
13
25
|
};
|
package/static/js/clientHooks.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// Modified from ep_image_insert 1.0.7
|
|
3
3
|
|
|
4
|
+
console.log('ep_images_extended version 1.1.1');
|
|
5
|
+
|
|
4
6
|
// Optional helper (shared with ep_docx_html_customizer) that provides a CORS fetch with
|
|
5
7
|
// automatic same-origin proxy fallback. If the plugin is not present we simply fall back
|
|
6
8
|
// to the native fetch logic.
|
|
@@ -892,8 +894,8 @@ exports.postAceInit = function (hook, context) {
|
|
|
892
894
|
if (isValid) {
|
|
893
895
|
evt.preventDefault();
|
|
894
896
|
|
|
895
|
-
// Determine storage strategy (default
|
|
896
|
-
const storageType = (clientVars && clientVars.ep_images_extended && clientVars.ep_images_extended.storageType) || '
|
|
897
|
+
// Determine storage strategy (default to s3_presigned)
|
|
898
|
+
const storageType = (clientVars && clientVars.ep_images_extended && clientVars.ep_images_extended.storageType) || 's3_presigned';
|
|
897
899
|
|
|
898
900
|
// Global cache to avoid re-uploading the same blob within a pad session
|
|
899
901
|
window.epImageInsertUploadCache = window.epImageInsertUploadCache || {};
|
|
@@ -964,8 +966,8 @@ exports.postAceInit = function (hook, context) {
|
|
|
964
966
|
probeImg.onerror = () => insertIntoPad(publicUrl);
|
|
965
967
|
probeImg.src = publicUrl;
|
|
966
968
|
} catch (err) {
|
|
967
|
-
console.error('[ep_images_extended paste] S3 upload failed
|
|
968
|
-
|
|
969
|
+
console.error('[ep_images_extended paste] S3 upload failed and base64 is disabled:', err);
|
|
970
|
+
$.gritter.add({ title: errorTitle, text: 'Image upload to S3 failed. Base64 is disabled.', sticky: true, class_name: 'error' });
|
|
969
971
|
}
|
|
970
972
|
})();
|
|
971
973
|
} else {
|
|
@@ -996,8 +998,8 @@ exports.postAceInit = function (hook, context) {
|
|
|
996
998
|
probeImg.onerror = () => insertIntoPad(publicUrl);
|
|
997
999
|
probeImg.src = publicUrl;
|
|
998
1000
|
} catch (err) {
|
|
999
|
-
console.error('[ep_images_extended paste] Server upload failed
|
|
1000
|
-
|
|
1001
|
+
console.error('[ep_images_extended paste] Server upload failed and base64 is disabled:', err);
|
|
1002
|
+
$.gritter.add({ title: errorTitle, text: 'Image upload failed. Base64 is disabled.', sticky: true, class_name: 'error' });
|
|
1001
1003
|
}
|
|
1002
1004
|
})();
|
|
1003
1005
|
}
|