Skip to content

Commit

Permalink
convertLabelToCamelCase should handle html strings too
Browse files Browse the repository at this point in the history
  • Loading branch information
Twiineenock committed Oct 7, 2024
1 parent 0020fa5 commit a710872
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/interactive-builder/add-question.modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,13 @@ const AddQuestionModal: React.FC<AddQuestionModalProps> = ({
};

const convertLabelToCamelCase = () => {
const camelCasedLabel = questionLabel
const extractTextFromHtml = (html: string) => {
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
return doc.body.textContent || "";
};

const camelCasedLabel = extractTextFromHtml(questionLabel)
?.toLowerCase()
?.replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => {
return index === 0 ? word.toLowerCase() : word.toUpperCase();
Expand Down

0 comments on commit a710872

Please sign in to comment.