Trigger the Command Palette and seed its string programmatically
i want to trigger action bar dynamically through javascript.
how can i do that??
@naumanumer What do you mean by action bar? The context menu? The F1 list? Or something else?
The F1 list (Command Palette).
editor.trigger('anyString', 'editor.action.quickCommand') should do it.
Is there a way to auto-populate the quick command search bar when opening it? Something like:
editor.trigger('anyString', 'editor.action.quickCommand', {
initialSearch: 'Initial search term',
});
@bradenhs No API of that sort at this time. PR welcome.
@nmanumr A bit hacky solution, but it one that work, is to simply change the value of the <input /> and trigger an input event on it.
editor.focus(); // Editor needs focus to be able to trigger command
editor.trigger("", "editor.action.quickCommand", ""); // Opens the quickcommand
const input = document.querySelector(".quick-input-box .input"); // Gets the quickcommand input
input.value = "> Your search string"; // Change the input value
input.dispatchEvent(new Event("input", { bubbles: true })); // Trigger an input event, for the search to register the new input value
Hi to all, I am writing this comment here since it was the place or thread I found I thought it was appropriate to what I am looking for. I would like to append some text to the editor after a suggestion has been selected. i.e. if a open element tag is inserted from the suggestion list, I would create the respective closing tag and insert it. pseudo code: insert "</" + tagname + ">". I am trying to learn how to use this tool. I am very new at it.
I really appreciate your help.
We closed this issue because we don't plan to address it in the foreseeable future. If you disagree and feel that this issue is crucial: we are happy to listen and to reconsider.
If you wonder what we are up to, please see our roadmap and issue reporting guidelines.
Thanks for your understanding, and happy coding!