Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix: render inline items with italic and bold

Marc Seitz1c7042425d94
diff --git a/components/datarooms/settings/introduction-settings.tsx b/components/datarooms/settings/introduction-settings.tsx
index cfd3c217..41b0c7b5 100644
--- a/components/datarooms/settings/introduction-settings.tsx
+++ b/components/datarooms/settings/introduction-settings.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useCallback, useEffect, useRef, useState } from "react";
+import React, { useCallback, useEffect, useRef, useState } from "react";
import { useTeam } from "@/context/team-context";
import { BookOpenIcon, EyeIcon } from "lucide-react";
@@ -337,6 +337,45 @@ function generateIntroductionContent(
};
}
+// Helper to render inline text nodes with marks (bold, italic, etc.)
+function renderInlineContent(nodes: any[] | undefined): React.ReactNode {
+ if (!nodes) return null;
+
+ return nodes.map((textNode: any, textIndex: number) => {
+ if (textNode.type === "text") {
+ let text: React.ReactNode = textNode.text;
+ if (textNode.marks) {
+ textNode.marks.forEach((mark: any) => {
+ if (mark.type === "bold") {
+ text = (
+ <strong key={`bold-${textIndex}`} className="font-semibold">
+ {text}
+ </strong>
+ );
+ } else if (mark.type === "italic") {
+ text = (
+ <em key={`italic-${textIndex}`} className="italic">
+ {text}
+ </em>
+ );
+ }
+ });
+ }
+ return <React.Fragment key={textIndex}>{text}</React.Fragment>;
+ } else if (textNode.type === "image") {
+ return (
+ <img
+ key={textIndex}
+ src={textNode.attrs?.src}
+ alt={textNode.attrs?.alt || ""}
+ className="my-2 h-auto max-w-full rounded-md"
+ />
+ );
+ }
+ return null;
+ });
+}
+
// Render TipTap JSON content for preview
function renderContent(content: any): React.ReactNode {
if (!content || !content.content) return null;
@@ -366,39 +405,7 @@ function renderContent(content: any): React.ReactNode {
} else if (node.type === "paragraph") {
return (
<p key={index} className="mb-3 text-sm leading-relaxed text-gray-700">
- {node.content?.map((textNode: any, textIndex: number) => {
- if (textNode.type === "text") {
- let text: React.ReactNode = textNode.text;
- if (textNode.marks) {
- textNode.marks.forEach((mark: any) => {
- if (mark.type === "bold") {
- text = (
- <strong key={textIndex} className="font-semibold">
- {text}
- </strong>
- );
- } else if (mark.type === "italic") {
- text = (
- <em key={textIndex} className="italic">
- {text}
- </em>
- );
- }
- });
- }
- return text;
- } else if (textNode.type === "image") {
- return (
- <img
- key={textIndex}
- src={textNode.attrs?.src}
- alt={textNode.attrs?.alt || ""}
- className="my-2 h-auto max-w-full rounded-md"
- />
- );
- }
- return null;
- }) ?? null}
+ {renderInlineContent(node.content)}
</p>
);
} else if (node.type === "bulletList") {
@@ -406,10 +413,7 @@ function renderContent(content: any): React.ReactNode {
<ul key={index} className="mb-3 list-disc pl-5 text-sm text-gray-700">
{node.content?.map((item: any, itemIndex: number) => (
<li key={itemIndex} className="mb-1">
- {item.content?.[0]?.content?.map(
- (textNode: any, textIndex: number) =>
- textNode.type === "text" ? textNode.text : null,
- )}
+ {renderInlineContent(item.content?.[0]?.content)}
</li>
))}
</ul>
@@ -422,10 +426,7 @@ function renderContent(content: any): React.ReactNode {
>
{node.content?.map((item: any, itemIndex: number) => (
<li key={itemIndex} className="mb-1">
- {item.content?.[0]?.content?.map(
- (textNode: any, textIndex: number) =>
- textNode.type === "text" ? textNode.text : null,
- )}
+ {renderInlineContent(item.content?.[0]?.content)}
</li>
))}
</ol>
diff --git a/components/view/dataroom/introduction-modal.tsx b/components/view/dataroom/introduction-modal.tsx
index 39b7a51a..76519562 100644
--- a/components/view/dataroom/introduction-modal.tsx
+++ b/components/view/dataroom/introduction-modal.tsx
@@ -80,6 +80,45 @@ export function IntroductionInfoButton() {
);
}
+// Helper to render inline text nodes with marks (bold, italic, etc.)
+function renderInlineContent(nodes: any[] | undefined): React.ReactNode {
+ if (!nodes) return null;
+
+ return nodes.map((textNode: any, textIndex: number) => {
+ if (textNode.type === "text") {
+ let text: React.ReactNode = textNode.text;
+ if (textNode.marks) {
+ textNode.marks.forEach((mark: any) => {
+ if (mark.type === "bold") {
+ text = (
+ <strong key={`bold-${textIndex}`} className="font-semibold">
+ {text}
+ </strong>
+ );
+ } else if (mark.type === "italic") {
+ text = (
+ <em key={`italic-${textIndex}`} className="italic">
+ {text}
+ </em>
+ );
+ }
+ });
+ }
+ return <React.Fragment key={textIndex}>{text}</React.Fragment>;
+ } else if (textNode.type === "image") {
+ return (
+ <img
+ key={textIndex}
+ src={textNode.attrs?.src}
+ alt={textNode.attrs?.alt || ""}
+ className="my-2 h-auto max-w-full rounded-md"
+ />
+ );
+ }
+ return null;
+ });
+}
+
// Render TipTap JSON content
function renderContent(content: any): React.ReactNode {
if (!content || !content.content) return null;
@@ -109,39 +148,7 @@ function renderContent(content: any): React.ReactNode {
} else if (node.type === "paragraph") {
return (
<p key={index} className="mb-3 text-sm leading-relaxed text-gray-700">
- {node.content?.map((textNode: any, textIndex: number) => {
- if (textNode.type === "text") {
- let text: React.ReactNode = textNode.text;
- if (textNode.marks) {
- textNode.marks.forEach((mark: any) => {
- if (mark.type === "bold") {
- text = (
- <strong key={textIndex} className="font-semibold">
- {text}
- </strong>
- );
- } else if (mark.type === "italic") {
- text = (
- <em key={textIndex} className="italic">
- {text}
- </em>
- );
- }
- });
- }
- return text;
- } else if (textNode.type === "image") {
- return (
- <img
- key={textIndex}
- src={textNode.attrs?.src}
- alt={textNode.attrs?.alt || ""}
- className="my-2 h-auto max-w-full rounded-md"
- />
- );
- }
- return null;
- }) ?? null}
+ {renderInlineContent(node.content)}
</p>
);
} else if (node.type === "bulletList") {
@@ -149,10 +156,7 @@ function renderContent(content: any): React.ReactNode {
<ul key={index} className="mb-3 list-disc pl-5 text-sm text-gray-700">
{node.content?.map((item: any, itemIndex: number) => (
<li key={itemIndex} className="mb-1">
- {item.content?.[0]?.content?.map(
- (textNode: any, textIndex: number) =>
- textNode.type === "text" ? textNode.text : null,
- )}
+ {renderInlineContent(item.content?.[0]?.content)}
</li>
))}
</ul>
@@ -165,10 +169,7 @@ function renderContent(content: any): React.ReactNode {
>
{node.content?.map((item: any, itemIndex: number) => (
<li key={itemIndex} className="mb-1">
- {item.content?.[0]?.content?.map(
- (textNode: any, textIndex: number) =>
- textNode.type === "text" ? textNode.text : null,
- )}
+ {renderInlineContent(item.content?.[0]?.content)}
</li>
))}
</ol>