How to call an added command from ribbon icon click

how to call an added command using addCommand from ribbon
how can I do an editorCallback like functionality from addRibbonIcon

Is this possible or am I doing something completely wrong ?

			id: 'sample-editor-command',
			name: 'Sample editor command',
			editorCallback: (editor: Editor, view: MarkdownView) => {
				editor.replaceSelection('Sample Editor Command');
this.addRibbonIcon("dice", "Print to console", (evt: MouseEvent) => {			
			// how do I call "sample-editor-command" here ?

8 days not a single reply. :frowning:
seems like this is not doable , there might be some unexplored way thats needs some digging.

1 Like

Just in case someone else needs this, here’s the solution.

this.addRibbonIcon('dice', 'To Live API', () => {

   //basically trawl through the app object, ensure you select command using the bracket notation and call the function [either callback or editorCallback()]
   // so more generically ==> app.commands.commands["plugin-id:command-id"].editorCallback()


There is probably an easier way but this is the way I found.