@salesforcedevs/docs-components
Advanced tools
Comparing version
{ | ||
"name": "@salesforcedevs/docs-components", | ||
"version": "0.0.9-edit", | ||
"version": "0.0.10-edit", | ||
"description": "Docs Lightning web components for DSC", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -40,3 +40,4 @@ import { LightningElement, api, track } from "lwc"; | ||
// API Configuration | ||
private static readonly FETCH_ENDPOINT = "https://1208ddd77328.ngrok-free.app/api/file-retrieval/retrieve"; | ||
private static readonly FETCH_ENDPOINT = | ||
"https://1208ddd77328.ngrok-free.app/api/file-retrieval/retrieve"; | ||
private static readonly SAVE_ENDPOINT = "/api/file/save"; | ||
@@ -62,3 +63,4 @@ | ||
"edit-file-button_primary", | ||
(this.isSaving || this.isContentUnchanged) && "edit-file-button_disabled" | ||
(this.isSaving || this.isContentUnchanged) && | ||
"edit-file-button_disabled" | ||
); | ||
@@ -73,3 +75,5 @@ } | ||
async handleEditClick() { | ||
if (this.disabled) return; | ||
if (this.disabled) { | ||
return; | ||
} | ||
@@ -94,3 +98,3 @@ this.isPopoverOpen = true; | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Content-Type": "application/json" | ||
}, | ||
@@ -113,11 +117,15 @@ body: JSON.stringify({ | ||
this.errorMessage = ""; | ||
// Set textarea value directly using ref | ||
this.updateTextareaValue(); | ||
} else { | ||
this.errorMessage = data.error || data.message || "Failed to load file content"; | ||
this.errorMessage = | ||
data.error || data.message || "Failed to load file content"; | ||
} | ||
} catch (error) { | ||
console.error("Error fetching file content:", error); | ||
this.errorMessage = error instanceof Error ? error.message : "Failed to connect to server"; | ||
this.errorMessage = | ||
error instanceof Error | ||
? error.message | ||
: "Failed to connect to server"; | ||
} finally { | ||
@@ -153,3 +161,5 @@ this.isLoading = false; | ||
async handleSave() { | ||
if (this.isSaving || this.isContentUnchanged || this.disabled) return; | ||
if (this.isSaving || this.isContentUnchanged || this.disabled) { | ||
return; | ||
} | ||
@@ -163,3 +173,3 @@ this.isSaving = true; | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Content-Type": "application/json" | ||
}, | ||
@@ -182,7 +192,7 @@ body: JSON.stringify({ | ||
this.isPopoverOpen = false; | ||
// Dispatch success event | ||
this.dispatchEvent( | ||
new CustomEvent("editsuccess", { | ||
detail: { | ||
detail: { | ||
fileName: this.fileName, | ||
@@ -195,7 +205,11 @@ content: this.fileContent, | ||
} else { | ||
this.errorMessage = data.error || data.message || "Failed to save file"; | ||
this.errorMessage = | ||
data.error || data.message || "Failed to save file"; | ||
} | ||
} catch (error) { | ||
console.error("Error saving file:", error); | ||
this.errorMessage = error instanceof Error ? error.message : "Failed to connect to server"; | ||
this.errorMessage = | ||
error instanceof Error | ||
? error.message | ||
: "Failed to connect to server"; | ||
} finally { | ||
@@ -224,3 +238,5 @@ this.isSaving = false; | ||
setTimeout(() => { | ||
const textarea = this.template.querySelector('#file-content') as HTMLTextAreaElement; | ||
const textarea = this.template.querySelector( | ||
"#file-content" | ||
) as HTMLTextAreaElement; | ||
if (textarea && this.fileContent !== undefined) { | ||
@@ -248,2 +264,2 @@ textarea.value = this.fileContent; | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
355150
0.07%8842
0.22%