@adminforth/markdown 1.6.0 → 1.8.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/build.log CHANGED
@@ -10,5 +10,5 @@ custom/package-lock.json
10
10
  custom/package.json
11
11
  custom/tsconfig.json
12
12
 
13
- sent 29,778 bytes received 115 bytes 59,786.00 bytes/sec
14
- total size is 29,346 speedup is 0.98
13
+ sent 29,849 bytes received 115 bytes 59,928.00 bytes/sec
14
+ total size is 29,417 speedup is 0.98
@@ -425,7 +425,7 @@ function markdownForUploadedFile(file: File, url: string): string {
425
425
 
426
426
  if (file.type?.startsWith('video/')) {
427
427
  const mediaType = file.type || 'video/mp4';
428
- return `<video width="400">\n<!-- For gif-like videos use: <video width="400" autoplay loop muted playsinline> -->\n <source src="${url}" type="${mediaType}">\n</video>`;
428
+ return `<figure>\n <!-- For gif-like videos use: <video width="500" autoplay loop muted playsinline> -->\n <video width="500" controls>\n <source src="${url}" type="${mediaType}">\n </video>\n <figcaption>Demo</figcaption>\n</figure>`;
429
429
  }
430
430
 
431
431
  // alert that file cant be uploaded
@@ -425,7 +425,7 @@ function markdownForUploadedFile(file: File, url: string): string {
425
425
 
426
426
  if (file.type?.startsWith('video/')) {
427
427
  const mediaType = file.type || 'video/mp4';
428
- return `<video width="400">\n<!-- For gif-like videos use: <video width="400" autoplay loop muted playsinline> -->\n <source src="${url}" type="${mediaType}">\n</video>`;
428
+ return `<figure>\n <!-- For gif-like videos use: <video width="500" autoplay loop muted playsinline> -->\n <video width="500" controls>\n <source src="${url}" type="${mediaType}">\n </video>\n <figcaption>Demo</figcaption>\n</figure>`;
429
429
  }
430
430
 
431
431
  // alert that file cant be uploaded
package/dist/index.js CHANGED
@@ -175,6 +175,16 @@ export default class MarkdownPlugin extends AdminForthPlugin {
175
175
  existing.title = next.title;
176
176
  }
177
177
  };
178
+ const normalizeAttachmentTitleForDb = (title) => {
179
+ // we can llow to use [xx] in titles, for some meta classes - so they will nto go to attachment titles, but will be available in the ending markdown
180
+ if (title === null) {
181
+ return null;
182
+ }
183
+ const cleaned = title
184
+ .replace(/\s*(?:\([^()]*\)|\[[^\[\]]*\])\s*$/, '')
185
+ .trim();
186
+ return cleaned || null;
187
+ };
178
188
  function getAttachmentMetas(markdown) {
179
189
  var _a, _b, _c, _d, _e, _f;
180
190
  if (!markdown) {
@@ -188,7 +198,7 @@ export default class MarkdownPlugin extends AdminForthPlugin {
188
198
  for (const match of markdown.matchAll(imageRegex)) {
189
199
  const altRaw = (_a = match[1]) !== null && _a !== void 0 ? _a : '';
190
200
  const srcRaw = match[2];
191
- const titleRaw = (_c = ((_b = match[3]) !== null && _b !== void 0 ? _b : match[4])) !== null && _c !== void 0 ? _c : null;
201
+ const titleRaw = normalizeAttachmentTitleForDb((_c = ((_b = match[3]) !== null && _b !== void 0 ? _b : match[4])) !== null && _c !== void 0 ? _c : null);
192
202
  const key = getKeyFromTrackedUrl(srcRaw);
193
203
  if (!key) {
194
204
  continue;
package/index.ts CHANGED
@@ -194,6 +194,17 @@ export default class MarkdownPlugin extends AdminForthPlugin {
194
194
  }
195
195
  };
196
196
 
197
+ const normalizeAttachmentTitleForDb = (title: string | null): string | null => {
198
+ // we can llow to use [xx] in titles, for some meta classes - so they will nto go to attachment titles, but will be available in the ending markdown
199
+ if (title === null) {
200
+ return null;
201
+ }
202
+ const cleaned = title
203
+ .replace(/\s*(?:\([^()]*\)|\[[^\[\]]*\])\s*$/, '')
204
+ .trim();
205
+ return cleaned || null;
206
+ };
207
+
197
208
  function getAttachmentMetas(markdown: string): AttachmentMeta[] {
198
209
  if (!markdown) {
199
210
  return [];
@@ -209,7 +220,7 @@ export default class MarkdownPlugin extends AdminForthPlugin {
209
220
  for (const match of markdown.matchAll(imageRegex)) {
210
221
  const altRaw = match[1] ?? '';
211
222
  const srcRaw = match[2];
212
- const titleRaw = (match[3] ?? match[4]) ?? null;
223
+ const titleRaw = normalizeAttachmentTitleForDb((match[3] ?? match[4]) ?? null);
213
224
 
214
225
  const key = getKeyFromTrackedUrl(srcRaw);
215
226
  if (!key) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/markdown",
3
- "version": "1.6.0",
3
+ "version": "1.8.0",
4
4
  "description": "Markdown plugin for adminforth",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",