LoginSignup
0
0

More than 5 years have passed since last update.

riot.js aceの記述errorヒントを検知する。

Last updated at Posted at 2018-04-12

対象のタグをquerySelectorするのが影響が少ない。

let isError=fn.q('.ace_error',ed.container);

同様にwaring等も検出できる。

全部

<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.3.3/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="//gnjo.github.io/riot.js"></script>
<ace></ace>

let fn=this.fn||{};
fn.q=(s,doc=document)=>{return doc.querySelector(s)};
fn.ace=(el)=>{
 var ed= ace.edit(el,{
  maxLines: 30,
  wrap: true,
  autoScrollEditorIntoView: true,
 }) 
 ed.setTheme("ace/theme/xcode");
 ed.session.setMode("ace/mode/javascript");
 ed.setOptions({useSoftTabs: true, tabSize: 1})
 return ed;
}
riot.tag(
 `ace`
 ,`<pre ref="code" oninput={input}></pre>`
 ,function(opts){
  let ed=null;
  this.one('mount',function(){ ed=fn.ace(this.refs.code) })
  this.input=function(ev){ 
    let isError=fn.q('.ace_error',ed.container);
    console.log(isError)
  }
 })       
riot.mount('ace')
;
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0