@griddo/ax 11.15.4-rc.0 → 11.15.5

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "11.15.4-rc.0",
4
+ "version": "11.15.5",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -219,5 +219,5 @@
219
219
  "publishConfig": {
220
220
  "access": "public"
221
221
  },
222
- "gitHead": "05aa8d8834e9691c0c6294abf95cb6edd013920f"
222
+ "gitHead": "bd040f49a71fc8eb3ced92dd17cd3e27bb885b36"
223
223
  }
@@ -121,6 +121,11 @@ FroalaEditor.DefineIcon("langIcon", {
121
121
  template: "svg",
122
122
  });
123
123
 
124
+ Object.assign(FroalaEditor.POPUP_TEMPLATES, {
125
+ "image.uploading": '[_CUSTOM_LAYER_]',
126
+ "image.uploadError": '[_CUSTOM_LAYER_]'
127
+ });
128
+
124
129
  FroalaEditor.RegisterCommand("langDropdown", {
125
130
  title: "Language",
126
131
  type: "dropdown",
@@ -51,7 +51,7 @@ const Wysiwyg = (props: IWysiwygProps) => {
51
51
  toolbarButtons: inline ? inlineToolbar() : full ? buttonsFull() : buttons(),
52
52
  toolbarInline: inline,
53
53
  charCounterCount: !inline,
54
- imageUpload: !!(full && !inline),
54
+ imageUpload: false,
55
55
  multiLine: !inline,
56
56
  enter: inline ? FroalaEditor.ENTER_BR : FroalaEditor.ENTER_P,
57
57
  requestHeaders: {
@@ -64,17 +64,81 @@ const Wysiwyg = (props: IWysiwygProps) => {
64
64
  if (disabled) {
65
65
  this.edit.off();
66
66
  }
67
- },
68
- "image.beforeUpload": async function (this: any, images: FileList) {
69
- try {
70
- const result = await uploadImage(images[0], imageSite);
71
- if (result) {
72
- this.image.insert(result.url, true, null, this.image.get(), null);
67
+
68
+ if (full && !inline) {
69
+ const editorEl = this.$el?.get?.(0) || this.el;
70
+ if (editorEl) {
71
+ const getPopupPosition = () => {
72
+ const editorRect = editorEl.getBoundingClientRect?.();
73
+ return {
74
+ x: editorRect ? editorRect.left + editorRect.width / 2 - 100 : window.innerWidth / 2 - 100,
75
+ y: editorRect ? editorRect.top + 50 : 50,
76
+ };
77
+ };
78
+
79
+ const showPopup = (name: string, template: any, keepVisible = false) => {
80
+ this.popups.create(name, template);
81
+ if (!keepVisible) {
82
+ this.popups.onHide(name, () => false);
83
+ }
84
+ const pos = getPopupPosition();
85
+ this.popups.show(name, pos.x, pos.y, 50);
86
+ };
87
+
88
+ const showErrorPopup = () => {
89
+ const errorPopupTemplate = {
90
+ custom_layer:
91
+ '<div style="padding: 15px 30px; text-align: center; color: #d32f2f;">Upload failed</div>',
92
+ };
93
+ showPopup("image.uploadError", errorPopupTemplate);
94
+ setTimeout(() => this.popups.hide("image.uploadError"), 3000);
95
+ };
96
+
97
+ editorEl.addEventListener("drop", async (e: DragEvent) => {
98
+ e.preventDefault();
99
+ const files = e.dataTransfer?.files;
100
+ if (files && files.length > 0) {
101
+ const imageFile = files[0];
102
+ if (imageFile.type.startsWith("image/")) {
103
+ let isUploading = true;
104
+ const uploadingTemplate = {
105
+ custom_layer:
106
+ '<div style="padding: 15px 30px; text-align: center; white-space: nowrap;">Image uploading...</div>',
107
+ };
108
+ this.popups.create("image.uploading", uploadingTemplate);
109
+ this.popups.onHide("image.uploading", () => {
110
+ if (isUploading) {
111
+ setTimeout(() => {
112
+ if (isUploading) {
113
+ const pos = getPopupPosition();
114
+ this.popups.show("image.uploading", pos.x, pos.y, 50);
115
+ }
116
+ }, 0);
117
+ }
118
+ });
119
+ const pos = getPopupPosition();
120
+ this.popups.show("image.uploading", pos.x, pos.y, 50);
121
+
122
+ try {
123
+ const result = await uploadImage(imageFile, imageSite);
124
+ isUploading = false;
125
+ this.popups.hide("image.uploading");
126
+ if (result) {
127
+ this.image.insert(result.url, true, null, this.image.get(), null);
128
+ } else {
129
+ showErrorPopup();
130
+ }
131
+ } catch (error) {
132
+ isUploading = false;
133
+ this.popups.hide("image.uploading");
134
+ showErrorPopup();
135
+ console.error("Upload failed:", error);
136
+ }
137
+ }
138
+ }
139
+ });
73
140
  }
74
- } catch {
75
- this.popups.hideAll();
76
141
  }
77
- return false;
78
142
  },
79
143
  blur: function (this: any) {
80
144
  const html = this.html.get();