TiddlyWiki / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
8.03k stars 1.19k forks source link

[IDEA] Extend notifications mechanism to make notifications more flexible. #7040

Open saqimtiaz opened 1 year ago

saqimtiaz commented 1 year ago

It would be desirable to extend the notifications mechanism with the following features:

The simple-notify library might provide some UI inspiration.


References:

saqimtiaz commented 1 year ago

It would also be interesting to explore implementing the notifications sub-system with wikitext:

Considerations:

Jermolene commented 1 year ago

Thank you for the summary @saqimtiaz. I'd add that we should make it possible to issue an alert without first creating a tiddler (one would still be created in the background of course). Something like:

<$action-sendmessage $type="tm-modal" text={{{ ... }}}/>

One minor point is that we're a bit constrained by the fact that the current implementation uses all the provided key/value pairs. So we can't use something as simple as "text" in case it was already in use. But using our tv- prefix should be sufficient:

<$action-sendmessage $type="tm-modal" tv-text={{{ ... }}}/>
oeyoews commented 1 year ago

I just tried to rewrite the simple-notify plugin for those cases where adding a tiddler is not required. Looks like it's working well so far

plugins demo

// widget
<$notify title="Test simple notify" />

// wikitext
<$button>
    <$action-sendmessage $message="om-notify" title="Just test simple notify" autoclose="false" />
    om-notify
</$button>
// For js developers, you can use `om-notify` to instead of `tm-notify`
this.parentWidget.dispatchEvent({
  type: 'om-notify',
  paramObject: options
});