@salesforcedevs/docs-components 0.0.8-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
|
|
|
@@ -108,7 +109,6 @@
|
|
|
108
109
|
<textarea
|
|
109
110
|
id="file-content"
|
|
110
111
|
class="edit-file-textarea"
|
|
111
|
-
value={fileContent}
|
|
112
112
|
oninput={handleContentChange}
|
|
113
113
|
placeholder="Enter file content..."
|
|
114
114
|
rows="20"
|
|
@@ -152,13 +152,11 @@
|
|
|
152
152
|
<div class="edit-file-button-spinner"></div>
|
|
153
153
|
Saving...
|
|
154
154
|
</template>
|
|
155
|
-
<template lwc:else>
|
|
156
|
-
Save
|
|
157
|
-
</template>
|
|
155
|
+
<template lwc:else>Save</template>
|
|
158
156
|
</button>
|
|
159
157
|
</div>
|
|
160
158
|
</div>
|
|
161
159
|
</div>
|
|
162
160
|
</div>
|
|
163
161
|
</template>
|
|
164
|
-
</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,12 +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 = "";
|
|
113
|
+
|
|
114
|
+
// Set textarea value directly using ref
|
|
115
|
+
this.updateTextareaValue();
|
|
109
116
|
} else {
|
|
110
|
-
this.errorMessage =
|
|
117
|
+
this.errorMessage =
|
|
118
|
+
data.error || data.message || "Failed to load file content";
|
|
111
119
|
}
|
|
112
120
|
} catch (error) {
|
|
113
121
|
console.error("Error fetching file content:", error);
|
|
114
|
-
this.errorMessage =
|
|
122
|
+
this.errorMessage =
|
|
123
|
+
error instanceof Error
|
|
124
|
+
? error.message
|
|
125
|
+
: "Failed to connect to server";
|
|
115
126
|
} finally {
|
|
116
127
|
this.isLoading = false;
|
|
117
128
|
}
|
|
@@ -142,7 +153,9 @@ export default class EditFile extends LightningElement {
|
|
|
142
153
|
|
|
143
154
|
// Handle save action
|
|
144
155
|
async handleSave() {
|
|
145
|
-
if (this.isSaving || this.isContentUnchanged || this.disabled)
|
|
156
|
+
if (this.isSaving || this.isContentUnchanged || this.disabled) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
146
159
|
|
|
147
160
|
this.isSaving = true;
|
|
148
161
|
this.errorMessage = "";
|
|
@@ -151,7 +164,7 @@ export default class EditFile extends LightningElement {
|
|
|
151
164
|
const response = await fetch(EditFile.SAVE_ENDPOINT, {
|
|
152
165
|
method: "POST",
|
|
153
166
|
headers: {
|
|
154
|
-
"Content-Type": "application/json"
|
|
167
|
+
"Content-Type": "application/json"
|
|
155
168
|
},
|
|
156
169
|
body: JSON.stringify({
|
|
157
170
|
fileName: this.fileName,
|
|
@@ -169,11 +182,11 @@ export default class EditFile extends LightningElement {
|
|
|
169
182
|
if (data.success) {
|
|
170
183
|
this.originalContent = this.fileContent;
|
|
171
184
|
this.isPopoverOpen = false;
|
|
172
|
-
|
|
185
|
+
|
|
173
186
|
// Dispatch success event
|
|
174
187
|
this.dispatchEvent(
|
|
175
188
|
new CustomEvent("editsuccess", {
|
|
176
|
-
detail: {
|
|
189
|
+
detail: {
|
|
177
190
|
fileName: this.fileName,
|
|
178
191
|
content: this.fileContent,
|
|
179
192
|
message: data.message || "File saved successfully"
|
|
@@ -181,11 +194,15 @@ export default class EditFile extends LightningElement {
|
|
|
181
194
|
})
|
|
182
195
|
);
|
|
183
196
|
} else {
|
|
184
|
-
this.errorMessage =
|
|
197
|
+
this.errorMessage =
|
|
198
|
+
data.error || data.message || "Failed to save file";
|
|
185
199
|
}
|
|
186
200
|
} catch (error) {
|
|
187
201
|
console.error("Error saving file:", error);
|
|
188
|
-
this.errorMessage =
|
|
202
|
+
this.errorMessage =
|
|
203
|
+
error instanceof Error
|
|
204
|
+
? error.message
|
|
205
|
+
: "Failed to connect to server";
|
|
189
206
|
} finally {
|
|
190
207
|
this.isSaving = false;
|
|
191
208
|
}
|
|
@@ -205,13 +222,33 @@ export default class EditFile extends LightningElement {
|
|
|
205
222
|
}
|
|
206
223
|
}
|
|
207
224
|
|
|
225
|
+
// Update textarea value using ref
|
|
226
|
+
private updateTextareaValue() {
|
|
227
|
+
// Use setTimeout to ensure DOM is updated
|
|
228
|
+
setTimeout(() => {
|
|
229
|
+
const textarea = this.template.querySelector(
|
|
230
|
+
"#file-content"
|
|
231
|
+
) as HTMLTextAreaElement;
|
|
232
|
+
if (textarea && this.fileContent !== undefined) {
|
|
233
|
+
textarea.value = this.fileContent;
|
|
234
|
+
}
|
|
235
|
+
}, 0);
|
|
236
|
+
}
|
|
237
|
+
|
|
208
238
|
connectedCallback() {
|
|
209
239
|
// Add escape key listener
|
|
210
240
|
document.addEventListener("keydown", this.handleKeyDown.bind(this));
|
|
211
241
|
}
|
|
212
242
|
|
|
243
|
+
renderedCallback() {
|
|
244
|
+
// Ensure textarea value is set correctly when component renders
|
|
245
|
+
if (this.isPopoverOpen && this.fileContent && !this.isLoading) {
|
|
246
|
+
this.updateTextareaValue();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
213
250
|
disconnectedCallback() {
|
|
214
251
|
// Remove escape key listener
|
|
215
252
|
document.removeEventListener("keydown", this.handleKeyDown.bind(this));
|
|
216
253
|
}
|
|
217
|
-
}
|
|
254
|
+
}
|