act.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var actAdd = function(macroContext,label,contents,flags={}){
  2. contents = (flags.contents_header ?? '') + contents + (flags.contents_footer ?? '');
  3. State.temporary.actions ??= [];
  4. State.temporary.actions.push( new setup.Action(
  5. {
  6. passage: passage(),
  7. label: label,
  8. contents: contents,
  9. /*priority: _priority,
  10. captured: _capture_vars_actionBar,
  11. styleClass: _styleClass,
  12. tooltip: _tooltip,
  13. image: flags.image*/
  14. })
  15. );
  16. }
  17. Macro.add('act', {
  18. skipArgs : false,
  19. tags:[],
  20. handler : function () {
  21. try {
  22. let label = this.args[0];
  23. let flags = this.args[1] ?? {};
  24. //flags.contents_header = '<<set _actions = []>><<replace ".passage">>';
  25. //flags.contents_footer = '<</replace>><<actionsRefresh>><<sidebarUpdate>>';
  26. flags.contents_header = '<<append ".passage">>';
  27. flags.contents_footer = "<<replace '#actions'>><<include 'Actions'>><</replace>><</append>>";
  28. actAdd(this,label,this.payload[0].contents,flags);
  29. }
  30. catch (ex) {
  31. return this.error('ERROR in act-widget: ' + ex.message);
  32. }
  33. }
  34. });