Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/app/components/ResumeForm/Form/InputGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,24 @@ const getBulletListStringsFromInnerText = (innerText: string) => {
return getStringsByLineBreak(newInnerText);
};

/**
* Escapes HTML special characters to prevent cursor jumping in ContentEditable.
* Note: & must be replaced first to avoid double-escaping.
*/
const escapeHTML = (str: string) => {
return str
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;");
};

const getHTMLFromBulletListStrings = (bulletListStrings: string[]) => {
// If bulletListStrings is an empty array, make it an empty div
if (bulletListStrings.length === 0) {
return "<div></div>";
}

return bulletListStrings.map((text) => `<div>${text}</div>`).join("");
return bulletListStrings.map((text) => `<div>${escapeHTML(text)}</div>`).join("");
};

/**
Expand Down