-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8429666
commit 43eb8e8
Showing
4 changed files
with
107 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from "./rich-text"; | ||
export { RichText, type RichTextProps } from "./rich-text"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
packages/basehub/src/react/rich-text/util/extract-text-from-react-node.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Node } from ".."; | ||
|
||
export function extractTextFromNode(node?: Node) { | ||
let textContent = ""; | ||
|
||
node?.content?.forEach((child) => { | ||
if (child.type === "text") { | ||
textContent += child.text; | ||
} | ||
if (child.content) { | ||
extractTextFromNode(child); | ||
} | ||
}); | ||
|
||
return textContent; | ||
} | ||
|
||
export function incrementID(id: string) { | ||
// duplicates are added "-n" at the end. | ||
// if the title already has a "-n" at the end, we'll need to increment it. | ||
const matches = id.match(/-(\d+)$/); // Fixed regex to match "-n" format | ||
if (matches?.[1] !== undefined) { | ||
const number = parseInt(matches[1]); | ||
return id.replace(/-(\d+)$/, `-${number + 1}`); | ||
} | ||
|
||
return `${id}-1`; | ||
} |