thlorenz / brace

📔 browserify compatible version of the ace editor.
http://thlorenz.github.io/brace/
MIT License
1.06k stars 304 forks source link

editor: assigning value during initialization of editor #198

Open meghna786 opened 6 months ago

meghna786 commented 6 months ago

I want to initialize the editor div with a query somewhere here-

this.editor = ace.edit("editor");
    this.editor.getSession().setMode("ace/mode/sql");

    const varIndex = window.variables.findIndex((item) => item.varName === this.newVar.varName);
    if (varIndex !== -1) {
      this.editor.setOption("placeholder", window.variables[varIndex].sqlQuery);
    } else {
      this.editor.setOption("placeholder", "Enter your SQL query here...");
    }

right now I'm using placeholder but I want the query to be editable and persist when user starts typing