mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 05:55:44 +01:00
Add extension point for changeset short links.
This commit is contained in:
@@ -35,14 +35,20 @@ type Props = {
|
||||
replacements: Replacement[];
|
||||
};
|
||||
|
||||
type PartToReplace = {
|
||||
start: number;
|
||||
length: number;
|
||||
replacement: ReactNode;
|
||||
const textWrapper = (s: string) => {
|
||||
const first = s.startsWith(" ") ? <> </> : "";
|
||||
const last = s.endsWith(" ") ? <> </> : "";
|
||||
return (
|
||||
<div>
|
||||
{first}
|
||||
{s}
|
||||
{last}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const SplitAndReplace: FC<Props> = ({ text, replacements }) => {
|
||||
const parts = textSplitAndReplace<ReactNode>(text, replacements, s => <div>{s}</div>);
|
||||
const parts = textSplitAndReplace<ReactNode>(text, replacements, textWrapper);
|
||||
if (parts.length === 0) {
|
||||
return <>{parts[0]}</>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user