Merge pull request #452 from ethereum/editor-dom

Remove DOM dependency of editor API
pull/1/head
yann300 8 years ago committed by GitHub
commit a6ece05c5e
  1. 4
      src/app.js
  2. 10
      src/app/editor.js

@ -157,7 +157,7 @@ var run = function () {
// ----------------- editor ----------------------
var editor = new Editor()
var editor = new Editor(document.getElementById('input'))
// ----------------- tabbed menu -------------------
$('#options li').click(function (ev) {
@ -487,7 +487,7 @@ var run = function () {
// ----------------- editor resize ---------------
function onResize () {
editor.resize()
editor.resize(document.querySelector('#editorWrap').checked)
reAdjust()
}
window.onresize = onResize

@ -6,9 +6,9 @@ var ace = require('brace')
var Range = ace.acequire('ace/range').Range
require('../mode-solidity.js')
function Editor () {
var editor = ace.edit('input')
document.getElementById('input').editor = editor // required to access the editor during tests
function Editor (editorElement) {
var editor = ace.edit(editorElement)
editorElement.editor = editor // required to access the editor during tests
var event = new EventManager()
this.event = event
var sessions = {}
@ -95,10 +95,10 @@ function Editor () {
}
}
this.resize = function () {
this.resize = function (useWrapMode) {
editor.resize()
var session = editor.getSession()
session.setUseWrapMode(document.querySelector('#editorWrap').checked)
session.setUseWrapMode(useWrapMode)
if (session.getUseWrapMode()) {
var characterWidth = editor.renderer.characterWidth
var contentWidth = editor.container.ownerDocument.getElementsByClassName('ace_scroller')[0].clientWidth

Loading…
Cancel
Save