From dedacabb534c7fcb8e11506c4625677b6e9ea715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Fincato?= Date: Mon, 18 Apr 2022 14:56:04 +0200 Subject: [PATCH] groups: add graph-url block below plain URL block this commit suggests a possible UI to put back the rich embed URL right below (aka in context) the block where the plain URL has been inserted. in this way when pasting a URL the formatting does not break and yet a richer UI is still rendered. --- .../components/Graph/GraphContent.tsx | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/pkg/interface/src/views/landscape/components/Graph/GraphContent.tsx b/pkg/interface/src/views/landscape/components/Graph/GraphContent.tsx index c2c1ace43..a0e746454 100644 --- a/pkg/interface/src/views/landscape/components/Graph/GraphContent.tsx +++ b/pkg/interface/src/views/landscape/components/Graph/GraphContent.tsx @@ -271,7 +271,7 @@ function stitchInlineAfterBlock(a: Root, b: GraphMentionNode[]) { } function stitchAsts(asts: [StitchMode, GraphAstNode][]) { - return _.reduce( + const t = _.reduce( asts, ([prevMode, ast], [mode, val]): [StitchMode, GraphAstNode] => { if (prevMode === 'block' || prevMode === 'inline') { @@ -298,6 +298,29 @@ function stitchAsts(asts: [StitchMode, GraphAstNode][]) { }, ['block', { type: 'root', children: [] }] as [StitchMode, GraphAstNode] ); + + t[1].children.map(c => { + if (c?.children) { + let links = []; + c.children.filter(k => { + if (k.type === 'link') { + links.push({ + type: 'root', + children: [ + { + type: 'graph-url', + url: k.url + } + ] + }) + } + }) + + c.children.push(...links); + } + }); + + return t } const header = ({ children, depth, ...rest }) => { const level = depth;