dotnet-smartcomponents / smartcomponents

Experimental, end-to-end AI features for .NET apps
693 stars 61 forks source link

SmartPasteButton - Use outside the form #29

Open spib opened 8 months ago

spib commented 8 months ago

Hi

This is awesome, thanks so much for putting this together.

My question is would it be possible to put the button outside the form tag and then add an attribute to tell it which for to use?

<smart-paste-button default-icon form=“myform” />

Our use case is that the button would ideally be positioned on the page above the form

SteveSandersonMS commented 8 months ago

Yes, that seems reasonable.

In the short term, you could work around this by putting the smart paste button inside the form, but using CSS to hide it (display: none). Then add a completely separate button into the page above the form, and script it so that when the user clicks it, it behaves as if the smart paste button was clicked, e.g.:

<button onclick="document.getElementById('my-smart-paste-button').click()">Smart Paste</button>

<form>
    <SmartPasteButton id="my-smart-paste-button" style="display:none" />
</form>

Of course, you could do it without the inline script in onclick in other ways, but hopefully you get the idea.