์ ๋ ์ธ๋ฏธ์ฝ๋ก ์ด ์๋ ์ฝ๋๋ฅผ ์ ๋ง ์ข์ํฉ๋๋ค. Ace๋ ํ๋ฅญํ์ง๋ง JavaScript์ ๋ํ ์ค๋ฅ ๋ณด๊ณ ๋ ์ธ๋ฏธ์ฝ๋ก ์์ด ์๋ฒฝํ๊ฒ ํ๋ฅญํ ์ฝ๋์ ๋ํด ๋ถํํฉ๋๋ค. ์ธ๋ฏธ์ฝ๋ก ์ ๋ํ ๊ฒฝ๊ณ ๋ฅผ ๋นํ์ฑํํ ์ ์์ต๋๊น? ๋ด๊ฐ ๊ด์ฌ ์๋ ๊ฒ์ ์คํ์ผ ์ค๋ฅ๊ฐ ์๋ ์ค์ ๊ตฌ๋ฌธ ์ค๋ฅ์ ๋๋ค.
์ํ ์ฝ๋(JavaScript):
alert("Hello, world!")
๋์ํ๋ค. ๋ฆฐํธ ๋๊ตฌ๋ฅผ ๊ตฌ์ฑํ ์ ์์ด์ผ ํฉ๋๋ค. ๋ชจ๋ ์ต์ ์ง์์ด ์ถ๊ฐ๋์์ผ๋ฏ๋ก(https://github.com/ajaxorg/ace/commit/10e2c3049cf2fd41a369336c4d03342127a618e2) php ์ธ๋ผ์ธ ๋ชจ๋ ์ต์ (https://github.com/ajaxorg/ace/commit/ 3a864c6056509ceeba2d290407dc91566c223d8e)
๊ทธ๊ฑด ๊ทธ๋ ๊ณ , ํ์ฌ ์ฝ๋์ ๋ค์ ์ฃผ์์ ์ถ๊ฐํ์ฌ ์ธ๋ฏธ์ฝ๋ก ๊ฒฝ๊ณ ๋ฅผ ๋นํ์ฑํํ ์ ์์ต๋๋ค. /* jshint asi:true */
๋๋ ๋ค์์ ์ํํ ์ ์์ต๋๋ค.
editor.session.$worker.send("changeOptions", [{asi: true}]);
์ด๊ฒ์ ๋ํ ์ ๋ฐ์ดํธ๊ฐ ์์ต๋๊น?
์ด๋ ๊ฒํด๋ ์๋ํ์ง ์์์ต๋๋ค.
editor.session.$worker.send("changeOptions", [{asi: true}]);
.$worker
๊ฐ null
์ด์๊ธฐ ๋๋ฌธ์
๋์ , ์ด๊ฒ์ ๋๋ฅผ ์ํด ์ผํ์ต๋๋ค (๋๊ตฐ๊ฐ๊ฐ ํ์ํ ๊ฒฝ์ฐ๋ฅผ ๋๋นํ์ฌ)
editor.session.on('changeMode', function(e, session) {
if('ace/mode/javascript' === session.getMode().$id) {
if(!!session.$worker) {
session.$worker.send('changeOptions', [{
asi: true // disable "Missing semicolon." warning in editor for JavaScript
}])
}
}
})
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋๋ ๋ค์์ ์ํํ ์ ์์ต๋๋ค.