@xuda.io/xuda-widget-plugin-xuda-drive 1.0.1 → 1.0.2

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.
Files changed (3) hide show
  1. package/index.mjs +2 -2
  2. package/package.json +1 -1
  3. package/runtime.mjs +26 -0
package/index.mjs CHANGED
@@ -72,8 +72,8 @@ export const methods = {
72
72
  label: "Drive Folder",
73
73
  type: "string",
74
74
  },
75
- upload_tags: {
76
- label: "Upload Set Tags",
75
+ file_tags: {
76
+ label: "File Tags",
77
77
  type: "string",
78
78
  tooltip: "Separate with commas",
79
79
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-widget-plugin-xuda-drive",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Xuda Drive widget plugin",
5
5
  "scripts": {
6
6
  "pub": "npm version patch --force && npm publish --access public"
package/runtime.mjs CHANGED
@@ -325,6 +325,32 @@ export async function upload(fields, e) {
325
325
  formData.append("folder", fields.file_upload_folder);
326
326
  formData.append("public", fields.public_file);
327
327
 
328
+ let tags = [];
329
+
330
+ if (fields.file_tags) {
331
+ function csvToArray(csvString) {
332
+ // Split the string into rows (by newline)
333
+ const rows = csvString.split("\n");
334
+
335
+ // Map through each row and split by commas to create arrays for each row
336
+ return rows.map((row) => row.split(","));
337
+ }
338
+ tags = csvToArray(fields.upload_tags);
339
+ }
340
+
341
+ if (fields.auto_tag_generator) {
342
+ let identifier = fields.auto_tag_identifier || " ";
343
+ let file_tags = file.name.split(identifier);
344
+ if (fields.auto_tag_translations) {
345
+ for (let tag of file_tags) {
346
+ if (auto_tag_translations[tag]) {
347
+ tag = auto_tag_translations[tag];
348
+ }
349
+ }
350
+ }
351
+ }
352
+ formData.append("tags", [...tags, ...file_tags]);
353
+
328
354
  const request = new XMLHttpRequest();
329
355
 
330
356
  let _domain = e._session.domain;