Show user input dialog


#1

Hi I’m a total newbie. I’m trying to create a package that shows up a user input dialog with a default input text “default.” But I can’t find a simple example that does this in javascript.

My lib/inputdialog.js is this:

 'use babel';



import {CompositeDisposable,TextEditor} from 'atom';

export default {

  inputdialogView: null,

 activate(state) {
    this.subscriptions = new CompositeDisposable();
    this.subscriptions.add(atom.commands.add('atom-workspace', {
  'inputdialog: Show Input Dialog': () => this.showInputDialog()
    }));
},

 deactivate() {
    subscriptions.dispose();
},

 showInputDialog() {

        element = document.createElement('div');
        miniEditor = document.createElement('atom-text-editor');
        miniEditor.setAttribute('mini', true);
    
    }  }

However, when I reload the window and run the “showInputDialog” command from the command palette, nothing shows up. What do I need to add to actually bring up a mini editor?

As long as this can be eventually extended into getting an actual user input, I won’t mind even if it’s not using a mini editor specifically. I just couldn’t find any other way that seems to make showing a user input box possible.

I looked at packages that show input dialog like tree-view package, but the code is too complicated for a newbie like me and I couldn’t figure out which part is specifically needed to bringing up a user input prompt.