@roomstay/frontend 2.6.89-0 → 2.6.89-2

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.
@@ -30,12 +30,29 @@ const HtmlContentViewer = ({ content }) => {
30
30
  const shadowRootContainer = (0, react_1.useRef)(null);
31
31
  (0, react_1.useEffect)(() => {
32
32
  if (shadowRootRef.current && !shadowRootContainer.current) {
33
- // Attach shadow DOM only once
34
33
  shadowRootContainer.current = shadowRootRef.current.attachShadow({ mode: 'open' });
35
34
  }
36
35
  if (shadowRootContainer.current) {
37
- // Update content inside the shadow DOM
38
- shadowRootContainer.current.innerHTML = content;
36
+ // If content is null, undefined, or empty, clear the shadow DOM
37
+ if (!content || content.trim() === '') {
38
+ shadowRootContainer.current.innerHTML = '';
39
+ }
40
+ else {
41
+ const hasHtmlTags = /<\/?[a-z][\s\S]*>/i.test(content);
42
+ let formattedContent;
43
+ if (hasHtmlTags) {
44
+ // HTML content → render directly without modification
45
+ formattedContent = content;
46
+ }
47
+ else {
48
+ // Plain text → replace line breaks and tabs for proper display
49
+ formattedContent = content
50
+ .replace(/\r?\n/g, '<br>') // Convert newlines to <br>
51
+ .replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;'); // Replace tabs with spaces
52
+ }
53
+ // Render inside the Shadow DOM
54
+ shadowRootContainer.current.innerHTML = formattedContent;
55
+ }
39
56
  }
40
57
  }, [content]);
41
58
  return react_1.default.createElement("div", { ref: shadowRootRef });
@@ -1 +1 @@
1
- {"version":3,"file":"HtmlContentViewer.js","sourceRoot":"/","sources":["src/components/generic/HtmlContentViewer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiD;AAE1C,MAAM,iBAAiB,GAAG,CAAC,EAAE,OAAO,EAAuB,EAAE,EAAE;IAClE,MAAM,aAAa,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IACnD,MAAM,mBAAmB,GAAG,IAAA,cAAM,EAAoB,IAAI,CAAC,CAAC;IAE5D,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,IAAI,aAAa,CAAC,OAAO,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE;YACvD,8BAA8B;YAC9B,mBAAmB,CAAC,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;SACtF;QAED,IAAI,mBAAmB,CAAC,OAAO,EAAE;YAC7B,uCAAuC;YACvC,mBAAmB,CAAC,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC;SACnD;IACL,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,uCAAK,GAAG,EAAE,aAAa,GAAQ,CAAC;AAC3C,CAAC,CAAC;AAjBW,QAAA,iBAAiB,qBAiB5B","sourcesContent":["import React, { useEffect, useRef } from 'react';\n\nexport const HtmlContentViewer = ({ content }: { content: string }) => {\n const shadowRootRef = useRef<HTMLDivElement>(null);\n const shadowRootContainer = useRef<ShadowRoot | null>(null);\n\n useEffect(() => {\n if (shadowRootRef.current && !shadowRootContainer.current) {\n // Attach shadow DOM only once\n shadowRootContainer.current = shadowRootRef.current.attachShadow({ mode: 'open' });\n }\n\n if (shadowRootContainer.current) {\n // Update content inside the shadow DOM\n shadowRootContainer.current.innerHTML = content;\n }\n }, [content]);\n\n return <div ref={shadowRootRef}></div>;\n};\n"]}
1
+ {"version":3,"file":"HtmlContentViewer.js","sourceRoot":"/","sources":["src/components/generic/HtmlContentViewer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiD;AAE1C,MAAM,iBAAiB,GAAG,CAAC,EAAE,OAAO,EAAuB,EAAE,EAAE;IAClE,MAAM,aAAa,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IACnD,MAAM,mBAAmB,GAAG,IAAA,cAAM,EAAoB,IAAI,CAAC,CAAC;IAE5D,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,IAAI,aAAa,CAAC,OAAO,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE;YACvD,mBAAmB,CAAC,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;SACtF;QAED,IAAI,mBAAmB,CAAC,OAAO,EAAE;YAC7B,gEAAgE;YAChE,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;gBACnC,mBAAmB,CAAC,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC;aAC9C;iBAAM;gBACH,MAAM,WAAW,GAAG,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACvD,IAAI,gBAAwB,CAAC;gBAE7B,IAAI,WAAW,EAAE;oBACb,sDAAsD;oBACtD,gBAAgB,GAAG,OAAO,CAAC;iBAC9B;qBAAM;oBACH,+DAA+D;oBAC/D,gBAAgB,GAAG,OAAO;yBACrB,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,2BAA2B;yBACrD,OAAO,CAAC,KAAK,EAAE,0BAA0B,CAAC,CAAC,CAAC,2BAA2B;iBAC/E;gBAED,+BAA+B;gBAC/B,mBAAmB,CAAC,OAAO,CAAC,SAAS,GAAG,gBAAgB,CAAC;aAC5D;SACJ;IACL,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,uCAAK,GAAG,EAAE,aAAa,GAAQ,CAAC;AAC3C,CAAC,CAAC;AAlCW,QAAA,iBAAiB,qBAkC5B","sourcesContent":["import React, { useEffect, useRef } from 'react';\n\nexport const HtmlContentViewer = ({ content }: { content: string }) => {\n const shadowRootRef = useRef<HTMLDivElement>(null);\n const shadowRootContainer = useRef<ShadowRoot | null>(null);\n\n useEffect(() => {\n if (shadowRootRef.current && !shadowRootContainer.current) {\n shadowRootContainer.current = shadowRootRef.current.attachShadow({ mode: 'open' });\n }\n\n if (shadowRootContainer.current) {\n // If content is null, undefined, or empty, clear the shadow DOM\n if (!content || content.trim() === '') {\n shadowRootContainer.current.innerHTML = '';\n } else {\n const hasHtmlTags = /<\\/?[a-z][\\s\\S]*>/i.test(content);\n let formattedContent: string;\n\n if (hasHtmlTags) {\n // HTML content → render directly without modification\n formattedContent = content;\n } else {\n // Plain text → replace line breaks and tabs for proper display\n formattedContent = content\n .replace(/\\r?\\n/g, '<br>') // Convert newlines to <br>\n .replace(/\\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;'); // Replace tabs with spaces\n }\n\n // Render inside the Shadow DOM\n shadowRootContainer.current.innerHTML = formattedContent;\n }\n }\n }, [content]);\n\n return <div ref={shadowRootRef}></div>;\n};\n"]}