ep_images_extended 1.0.61 → 1.1.0

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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  `ep_images_extended` builds on `ep_image_insert` and other image upload plugins.
5
5
  The main difference is that images are built as custom span structures using the CSS background image attribute. This bypasses the Content Collector which always requires images to be block-level styles (so they couldn't share the line with text). As a result, we can now type around images, which allows the creation of more interactive pad content. The plugin includes some other features like click + drag resize, image float, and cut/copy/delete through a context menu. It was designed for compatibility with my forthcoming tables plugin. It's a pretty heavyweight plugin (some would say overengineered), because I was prioritizing meeting functional requirements for my project. Etherpad wizards might have tips for optimization, it would surely be appreciated.
6
6
 
7
- ![Demo](https://i.imgur.com/JdyA50U.png)
7
+ ![Demo](https://i.imgur.com/qGOBRep.png)
8
8
 
9
9
  ## Installation
10
10
 
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
- const settings = require('ep_etherpad-lite/node/utils/Settings');
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');
@@ -22,8 +24,14 @@ try {
22
24
  console.warn('[ep_images_extended] AWS SDK not installed; s3_presigned storage will not work.');
23
25
  }
24
26
 
25
- // Removed log4js; use built-in console for logging
26
- const logger = console;
27
+ // Replaced log4js with lightweight console wrapper to avoid external dependency
28
+ // while preserving same API surface used below.
29
+ const logger = {
30
+ debug: console.debug.bind(console),
31
+ info: console.info.bind(console),
32
+ warn: console.warn.bind(console),
33
+ error: console.error.bind(console),
34
+ };
27
35
 
28
36
  // Simple in-memory IP rate limiter
29
37
  const _presignRateStore = new Map();
@@ -178,6 +186,9 @@ exports.expressConfigure = (hookName, context) => {
178
186
 
179
187
  // ADD LOCAL DISK STORAGE UPLOAD ENDPOINT ------------------------------
180
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
+
181
192
  if (settings.ep_images_extended && settings.ep_images_extended.storage && settings.ep_images_extended.storage.type === 'local') {
182
193
  // Route: POST /p/:padId/pluginfw/ep_images_extended/upload
183
194
  // Accepts multipart/form-data with field "file" and saves it to the
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ep_images_extended",
3
3
  "description": "Insert images inline with text, float them, resize them, and more.",
4
- "version": "1.0.61",
4
+ "version": "1.1.0",
5
5
  "author": {
6
6
  "name": "DCastelone",
7
7
  "url": "https://github.com/dcastelone"
package/settings.js CHANGED
@@ -2,12 +2,24 @@
2
2
 
3
3
  'use strict';
4
4
 
5
- exports.loadSettings = (hookName, settings, cb) => {
6
- if (!settings.settings.socketIo) {
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
- settings.settings.socketIo.maxHttpBufferSize = 100000000;
22
+ args.settings.socketIo.maxHttpBufferSize = 100000000;
11
23
  }
12
24
  cb();
13
25
  };
@@ -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
- const response = await fetch(imageSrc, { mode: 'cors' });
1150
- if (!response.ok) {
1151
- throw new Error(`HTTP ${response.status}`);
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