{"version":3,"file":"DRichText-00fc2b77.js","sources":["../../client/packages/design-system/src/composables/useHTMLRender.ts","../../client/packages/design-system/src/atoms/DRichText.vue"],"sourcesContent":["export function useHTMLRender(html: string) {\n const processedHtml = html;\n\n const array = [\n // Handle P first so following P tags are not affected\n {\n element: \"p\",\n class: \"p-4\",\n },\n {\n element: \"h1\",\n class: \"h-1\",\n },\n {\n element: \"h2\",\n class: \"h-2\",\n },\n {\n element: \"h3\",\n class: \"h-3\",\n },\n {\n element: \"h4\",\n class: \"h-4\",\n },\n {\n element: \"h5\",\n class: \"h-5\",\n },\n {\n element: \"h6\",\n class: \"h-6\",\n },\n {\n element: \"blockquote\",\n class: \"l-1\",\n },\n ];\n\n const parser = new DOMParser();\n const doc = parser.parseFromString(processedHtml, \"text/html\");\n\n const hasBlockElements = array.some(({element}) => doc.querySelector(element));\n\n if (!hasBlockElements) {\n const wrapper = doc.createElement(\"p\");\n wrapper.innerHTML = processedHtml;\n doc.body.innerHTML = \"\";\n doc.body.appendChild(wrapper);\n }\n\n\n array.forEach((tag) => {\n doc.querySelectorAll(tag.element).forEach((element) => {\n // Add or merge the class attribute\n const existingClass = element.getAttribute(\"class\") || \"\";\n element.setAttribute(\"class\", `${existingClass} ${tag.class}`.trim());\n\n // Replace the tag name if necessary\n if (element.tagName.toLowerCase() !== \"p\") {\n const newElement = doc.createElement(\"p\");\n // Copy all attributes and child nodes to the new
element\n Array.from(element.attributes).forEach((attr) => {\n newElement.setAttribute(attr.name, attr.value);\n });\n newElement.innerHTML = element.innerHTML;\n element.replaceWith(newElement);\n }\n });\n });\n\n return {htmlContent: doc.body.innerHTML};\n}","\n