@salesforcedevs/docs-components 0.0.9-edit → 0.0.10-edit
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
|
@@ -242,7 +242,8 @@
|
|
|
242
242
|
padding: 16px;
|
|
243
243
|
border: 2px solid #e5e7ea;
|
|
244
244
|
border-radius: 12px;
|
|
245
|
-
font-family: "SF Mono",
|
|
245
|
+
font-family: "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New",
|
|
246
|
+
monospace;
|
|
246
247
|
font-size: 14px;
|
|
247
248
|
line-height: 1.5;
|
|
248
249
|
resize: vertical;
|
|
@@ -375,7 +376,7 @@
|
|
|
375
376
|
width: 16px;
|
|
376
377
|
height: 16px;
|
|
377
378
|
border: 2px solid transparent;
|
|
378
|
-
border-top: 2px solid
|
|
379
|
+
border-top: 2px solid currentcolor;
|
|
379
380
|
border-radius: 50%;
|
|
380
381
|
animation: edit-file-spin 1s linear infinite;
|
|
381
382
|
}
|
|
@@ -508,4 +509,4 @@
|
|
|
508
509
|
.edit-file-button {
|
|
509
510
|
border: 2px solid;
|
|
510
511
|
}
|
|
511
|
-
}
|
|
512
|
+
}
|
|
@@ -25,10 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
<!-- Popover Overlay -->
|
|
27
27
|
<template lwc:if={isPopoverOpen}>
|
|
28
|
-
<div
|
|
29
|
-
class={overlayClass}
|
|
30
|
-
onclick={handleOverlayClick}
|
|
31
|
-
>
|
|
28
|
+
<div class={overlayClass} onclick={handleOverlayClick}>
|
|
32
29
|
<div class={popoverClass}>
|
|
33
30
|
<!-- Popover Header -->
|
|
34
31
|
<div class="edit-file-header">
|
|
@@ -78,7 +75,9 @@
|
|
|
78
75
|
<template lwc:if={isLoading}>
|
|
79
76
|
<div class="edit-file-loading">
|
|
80
77
|
<div class="edit-file-spinner"></div>
|
|
81
|
-
<p class="edit-file-loading-text">
|
|
78
|
+
<p class="edit-file-loading-text">
|
|
79
|
+
Loading file content...
|
|
80
|
+
</p>
|
|
82
81
|
</div>
|
|
83
82
|
</template>
|
|
84
83
|
|
|
@@ -95,7 +94,9 @@
|
|
|
95
94
|
<line x1="15" y1="9" x2="9" y2="15"></line>
|
|
96
95
|
<line x1="9" y1="9" x2="15" y2="15"></line>
|
|
97
96
|
</svg>
|
|
98
|
-
<span class="edit-file-error-text">
|
|
97
|
+
<span class="edit-file-error-text">
|
|
98
|
+
{errorMessage}
|
|
99
|
+
</span>
|
|
99
100
|
</div>
|
|
100
101
|
</template>
|
|
101
102
|
|
|
@@ -151,13 +152,11 @@
|
|
|
151
152
|
<div class="edit-file-button-spinner"></div>
|
|
152
153
|
Saving...
|
|
153
154
|
</template>
|
|
154
|
-
<template lwc:else>
|
|
155
|
-
Save
|
|
156
|
-
</template>
|
|
155
|
+
<template lwc:else>Save</template>
|
|
157
156
|
</button>
|
|
158
157
|
</div>
|
|
159
158
|
</div>
|
|
160
159
|
</div>
|
|
161
160
|
</div>
|
|
162
161
|
</template>
|
|
163
|
-
</template>
|
|
162
|
+
</template>
|
|
@@ -37,7 +37,8 @@ export default class EditFile extends LightningElement {
|
|
|
37
37
|
private _disabled: boolean = false;
|
|
38
38
|
|
|
39
39
|
// API Configuration
|
|
40
|
-
private static readonly FETCH_ENDPOINT =
|
|
40
|
+
private static readonly FETCH_ENDPOINT =
|
|
41
|
+
"https://1208ddd77328.ngrok-free.app/api/file-retrieval/retrieve";
|
|
41
42
|
private static readonly SAVE_ENDPOINT = "/api/file/save";
|
|
42
43
|
|
|
43
44
|
get popoverClass() {
|
|
@@ -58,7 +59,8 @@ export default class EditFile extends LightningElement {
|
|
|
58
59
|
return cx(
|
|
59
60
|
"edit-file-button",
|
|
60
61
|
"edit-file-button_primary",
|
|
61
|
-
(this.isSaving || this.isContentUnchanged) &&
|
|
62
|
+
(this.isSaving || this.isContentUnchanged) &&
|
|
63
|
+
"edit-file-button_disabled"
|
|
62
64
|
);
|
|
63
65
|
}
|
|
64
66
|
|
|
@@ -68,7 +70,9 @@ export default class EditFile extends LightningElement {
|
|
|
68
70
|
|
|
69
71
|
// Open the edit file popover
|
|
70
72
|
async handleEditClick() {
|
|
71
|
-
if (this.disabled)
|
|
73
|
+
if (this.disabled) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
72
76
|
|
|
73
77
|
this.isPopoverOpen = true;
|
|
74
78
|
this.errorMessage = "";
|
|
@@ -88,7 +92,7 @@ export default class EditFile extends LightningElement {
|
|
|
88
92
|
const response = await fetch(EditFile.FETCH_ENDPOINT, {
|
|
89
93
|
method: "POST",
|
|
90
94
|
headers: {
|
|
91
|
-
"Content-Type": "application/json"
|
|
95
|
+
"Content-Type": "application/json"
|
|
92
96
|
},
|
|
93
97
|
body: JSON.stringify({
|
|
94
98
|
source: this.source,
|
|
@@ -106,15 +110,19 @@ export default class EditFile extends LightningElement {
|
|
|
106
110
|
this.fileContent = data.data.content;
|
|
107
111
|
this.originalContent = data.data.content;
|
|
108
112
|
this.errorMessage = "";
|
|
109
|
-
|
|
113
|
+
|
|
110
114
|
// Set textarea value directly using ref
|
|
111
115
|
this.updateTextareaValue();
|
|
112
116
|
} else {
|
|
113
|
-
this.errorMessage =
|
|
117
|
+
this.errorMessage =
|
|
118
|
+
data.error || data.message || "Failed to load file content";
|
|
114
119
|
}
|
|
115
120
|
} catch (error) {
|
|
116
121
|
console.error("Error fetching file content:", error);
|
|
117
|
-
this.errorMessage =
|
|
122
|
+
this.errorMessage =
|
|
123
|
+
error instanceof Error
|
|
124
|
+
? error.message
|
|
125
|
+
: "Failed to connect to server";
|
|
118
126
|
} finally {
|
|
119
127
|
this.isLoading = false;
|
|
120
128
|
}
|
|
@@ -145,7 +153,9 @@ export default class EditFile extends LightningElement {
|
|
|
145
153
|
|
|
146
154
|
// Handle save action
|
|
147
155
|
async handleSave() {
|
|
148
|
-
if (this.isSaving || this.isContentUnchanged || this.disabled)
|
|
156
|
+
if (this.isSaving || this.isContentUnchanged || this.disabled) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
149
159
|
|
|
150
160
|
this.isSaving = true;
|
|
151
161
|
this.errorMessage = "";
|
|
@@ -154,7 +164,7 @@ export default class EditFile extends LightningElement {
|
|
|
154
164
|
const response = await fetch(EditFile.SAVE_ENDPOINT, {
|
|
155
165
|
method: "POST",
|
|
156
166
|
headers: {
|
|
157
|
-
"Content-Type": "application/json"
|
|
167
|
+
"Content-Type": "application/json"
|
|
158
168
|
},
|
|
159
169
|
body: JSON.stringify({
|
|
160
170
|
fileName: this.fileName,
|
|
@@ -172,11 +182,11 @@ export default class EditFile extends LightningElement {
|
|
|
172
182
|
if (data.success) {
|
|
173
183
|
this.originalContent = this.fileContent;
|
|
174
184
|
this.isPopoverOpen = false;
|
|
175
|
-
|
|
185
|
+
|
|
176
186
|
// Dispatch success event
|
|
177
187
|
this.dispatchEvent(
|
|
178
188
|
new CustomEvent("editsuccess", {
|
|
179
|
-
detail: {
|
|
189
|
+
detail: {
|
|
180
190
|
fileName: this.fileName,
|
|
181
191
|
content: this.fileContent,
|
|
182
192
|
message: data.message || "File saved successfully"
|
|
@@ -184,11 +194,15 @@ export default class EditFile extends LightningElement {
|
|
|
184
194
|
})
|
|
185
195
|
);
|
|
186
196
|
} else {
|
|
187
|
-
this.errorMessage =
|
|
197
|
+
this.errorMessage =
|
|
198
|
+
data.error || data.message || "Failed to save file";
|
|
188
199
|
}
|
|
189
200
|
} catch (error) {
|
|
190
201
|
console.error("Error saving file:", error);
|
|
191
|
-
this.errorMessage =
|
|
202
|
+
this.errorMessage =
|
|
203
|
+
error instanceof Error
|
|
204
|
+
? error.message
|
|
205
|
+
: "Failed to connect to server";
|
|
192
206
|
} finally {
|
|
193
207
|
this.isSaving = false;
|
|
194
208
|
}
|
|
@@ -212,7 +226,9 @@ export default class EditFile extends LightningElement {
|
|
|
212
226
|
private updateTextareaValue() {
|
|
213
227
|
// Use setTimeout to ensure DOM is updated
|
|
214
228
|
setTimeout(() => {
|
|
215
|
-
const textarea = this.template.querySelector(
|
|
229
|
+
const textarea = this.template.querySelector(
|
|
230
|
+
"#file-content"
|
|
231
|
+
) as HTMLTextAreaElement;
|
|
216
232
|
if (textarea && this.fileContent !== undefined) {
|
|
217
233
|
textarea.value = this.fileContent;
|
|
218
234
|
}
|
|
@@ -235,4 +251,4 @@ export default class EditFile extends LightningElement {
|
|
|
235
251
|
// Remove escape key listener
|
|
236
252
|
document.removeEventListener("keydown", this.handleKeyDown.bind(this));
|
|
237
253
|
}
|
|
238
|
-
}
|
|
254
|
+
}
|