Skip to content

Let group optionally display description info below nodes within the group - #5389

Open
dceejay wants to merge 8 commits into
devfrom
Let-group-show-description-info
Open

dceejay wants to merge 8 commits into
devfrom
Let-group-show-description-info

Conversation

@dceejay

@dceejay dceejay commented Dec 16, 2025

Copy link
Copy Markdown
Member

…group

to help folk doc flows more visibly

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Proposed changes

Based of this discussion https://discourse.nodered.org/t/ways-to-improve-flow-documentation/99924
This PR adds an optional checkbox to the group config that when enabled shows the raw text from the description tab as visible text below the nodes in the group.

We can't easily render markdown as SVG so this just adds the raw text - but does respect line breaks so the user can create useful documentation.

Screenshot 2025-12-16 at 09 29 02

Checklist

  • I have read the contribution guidelines
  • For non-bugfix PRs, I have discussed this change on the forum/slack team.
  • I have run npm run test to verify the unit tests pass
  • I have added suitable unit tests to cover the new/changed functionality

@Steve-Mcl

Copy link
Copy Markdown
Contributor

Would be lovely if the text was rendered markdown?

Perhaps a foreignObject would work (and perhaps simpler than computing SVG elements from split text?)? 🤔

Something like

<svg xmlns="http://www.w3.org/2000/svg">
  <foreignObject width="100%" height="100%">

    <div xmlns="http://www.w3.org/1999/xhtml">

      <rendered markdown here>

    </div>
  </foreignObject>
</svg>

@dceejay

dceejay commented Dec 16, 2025 •

Copy link
Copy Markdown
Member Author

OK - I'll let you work out the maths for the size of the group boundary !

Though I do feel that as others have pointed out - if we went full markdown and diagrams in the editor it would take up too much space permanently... the compressed font and text that we have now doesn't seem too bad... so I'm not feeling the urge to try for extending to markdown rendering. Of course other PR's are available...

I think there are better options for much wordier docs - like click to expand or separate windows etc.

@dceejay dceejay added this to the 5.0 milestone Dec 18, 2025
@Steve-Mcl

Copy link
Copy Markdown
Contributor

OK - I'll let you work out the maths for the size of the group boundary !

Yep, tricky indeed.

I had another thought - If the group (and the tab) had the same note icon support as regular nodes do, we could use use the popover API and show rendered callout - then i remembered the worksace is an SVG (popover api not supported - bah)

Never mind, good old fashion event handlers to the rescue - a quick play - and this is what we could achieve quite cheaply...

chrome_eIztfdOFa6

NOTE: for the group note icon i just modified the group SVG and pasted one in - that would need to utelise whatever was added fro showing a note icon over a node.

Paste the below into your console then hover your nodes:

// Clean up existing popover if it exists, or ensure we have one
let popover = document.getElementById('dynamic-svg-popover');
if (!popover) {
    popover = document.createElement('div');
    popover.id = 'dynamic-svg-popover';
    popover.popover = 'auto';
    document.body.appendChild(popover);
}

// styling for the popover
Object.assign(popover.style, {
    padding: '12px',
    borderRadius: '8px',
    border: '1px solid #ccc',
    boxShadow: '0 4px 15px rgba(0,0,0,0.15)',
    fontSize: '14px',
    maxWidth: '350px',
    position: 'fixed',
    margin: '0',
    pointerEvents: 'auto',
    zIndex: '10000'
});

let hideTimeout;

// Shared Event Handlers
const showPopover = (event) => {
    clearTimeout(hideTimeout);
    const target = event.currentTarget;
    const parentG = target.closest('g[id]');
    let nodeId = parentG ? parentG.id : null;
    popover.innerHTML = ''
    popover.hidePopover()
    if (nodeId && typeof RED !== 'undefined') {
        try {
            let nodeGetter = RED.nodes.node
            if (nodeId.startsWith('group_select_')) {
                nodeId = nodeId.replace('group_select_', '');
                nodeGetter = RED.nodes.group
            }
            const node = nodeGetter(nodeId);
            const info = node ? (node.info || node._def?.info) : null;
            
            if (info) {
                const htmlStr = RED.utils.renderMarkdown(info);
                popover.innerHTML = `<div class="red-ui-help"><span class="red-ui-text-bidi-aware">${htmlStr}</span></div>`;
            } else {
                popover.innerHTML = '<div class="red-ui-help">No documentation available.</div>';
            }
        } catch (e) {
            popover.innerHTML = '<div class="red-ui-help">Error rendering documentation.</div>';
        }

        const rect = target.getBoundingClientRect();
        popover.style.top = (rect.bottom + 5) + 'px';
        popover.style.left = rect.left + 'px';
        popover.showPopover();
    }
};

const hidePopover = () => {
    hideTimeout = setTimeout(() => {
        popover.hidePopover();
    }, 150);
};

// Apply to ALL documentation icons in the SVG
const allDocIcons = document.querySelectorAll('.red-ui-flow-node-docs'); // should probably tighten this
allDocIcons.forEach(icon => {
    // Clear old listeners if any (using property assignment for simplicity in this experiment)
    icon.onmouseenter = showPopover;
    icon.onmouseleave = hidePopover;
});

// Keep popover open when hovering the popover itself
popover.onmouseenter = () => clearTimeout(hideTimeout);
popover.onmouseleave = hidePopover;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants