Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Southclaws committed Nov 17, 2023
1 parent 5dd2a24 commit a27f5d1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion web/src/components/content/ContentComposer/render/Element.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropsWithChildren } from "react";
import { Children, PropsWithChildren, ReactNode } from "react";
import { RenderElementProps } from "slate-react";

import { styled } from "@/styled-system/jsx";
Expand All @@ -10,6 +10,22 @@ export function Element({
}: PropsWithChildren<RenderElementProps>) {
switch (element.type) {
case "paragraph":
if (element.children.length === 1 && element.children[0]) {
const content = element.children[0];

try {
const parsed = new URL(content.text);

return (
<styled.a href={parsed.toString()} {...attributes}>
{children}
</styled.a>
);
} catch (_) {
//
}
}

return <styled.p {...attributes}>{children}</styled.p>;

case "link":
Expand Down

0 comments on commit a27f5d1

Please sign in to comment.