@mbs-dev/react-editor 1.4.0 → 1.5.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/dist/Editor.js CHANGED
@@ -67,7 +67,14 @@ var getDisplayNameFromPath = function (filename) {
67
67
  var _a, _b;
68
68
  var clean = (_b = (_a = (filename || '').split('?')[0]) === null || _a === void 0 ? void 0 : _a.split('#')[0]) !== null && _b !== void 0 ? _b : '';
69
69
  var last = clean.split('/').pop();
70
- return last ? decodeURIComponent(last) : filename;
70
+ var base = last ? decodeURIComponent(last) : filename;
71
+ var dotIndex = base.lastIndexOf('.');
72
+ var noExt = dotIndex > 0 ? base.slice(0, dotIndex) : base;
73
+ var dashIndex = noExt.lastIndexOf('-');
74
+ if (dashIndex > 0) {
75
+ return noExt.slice(0, dashIndex);
76
+ }
77
+ return noExt;
71
78
  };
72
79
  var uploaderConfig = function (apiUrl, imageUrl) { return ({
73
80
  imagesExtensions: ['jpg', 'png', 'jpeg', 'gif', 'webp'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mbs-dev/react-editor",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "react editor",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",
package/src/Editor.tsx CHANGED
@@ -19,10 +19,24 @@ const isImageByExtension = (filename: string, imageExts: string[]): boolean => {
19
19
  return !!ext && imageExts.includes(ext);
20
20
  };
21
21
 
22
+ // ✅ UPDATED: for files, display name without extension and without last "-..."
23
+ // Example: recu-202600004-2-69956651a3b98099024323.pdf -> recu-202600004-2
22
24
  const getDisplayNameFromPath = (filename: string): string => {
23
25
  const clean = (filename || '').split('?')[0]?.split('#')[0] ?? '';
24
26
  const last = clean.split('/').pop();
25
- return last ? decodeURIComponent(last) : filename;
27
+ const base = last ? decodeURIComponent(last) : filename;
28
+
29
+ // remove extension
30
+ const dotIndex = base.lastIndexOf('.');
31
+ const noExt = dotIndex > 0 ? base.slice(0, dotIndex) : base;
32
+
33
+ // remove last "-..." suffix
34
+ const dashIndex = noExt.lastIndexOf('-');
35
+ if (dashIndex > 0) {
36
+ return noExt.slice(0, dashIndex);
37
+ }
38
+
39
+ return noExt;
26
40
  };
27
41
 
28
42
  /**
@@ -139,7 +153,7 @@ export const config = ({
139
153
  'ol',
140
154
  '|',
141
155
  'image',
142
- 'file', // ✅ added
156
+ 'file',
143
157
  '|',
144
158
  'video',
145
159
  '|',