Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
d33aa9fe
Commit
d33aa9fe
authored
Jul 04, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move editorOnChange to editor
parent
66fc6020
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
35 deletions
+39
-35
app.js
src/app.js
+1
-34
editor.js
src/app/editor/editor.js
+38
-1
No files found.
src/app.js
View file @
d33aa9fe
...
@@ -486,39 +486,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
...
@@ -486,39 +486,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
self
.
_components
.
righthandpanel
.
init
()
self
.
_components
.
righthandpanel
.
init
()
self
.
_components
.
righthandpanel
.
event
.
register
(
'resize'
,
delta
=>
self
.
_adjustLayout
(
'right'
,
delta
))
self
.
_components
.
righthandpanel
.
event
.
register
(
'resize'
,
delta
=>
self
.
_adjustLayout
(
'right'
,
delta
))
var
txLogger
=
new
TxLogger
()
// eslint-disable-line
var
txLogger
=
new
TxLogger
()
// eslint-disable-line
var
previousInput
=
''
var
saveTimeout
=
null
function
editorOnChange
()
{
var
currentFile
=
self
.
_components
.
config
.
get
(
'currentFile'
)
if
(
!
currentFile
)
{
return
}
var
input
=
editor
.
get
(
currentFile
)
if
(
!
input
)
{
return
}
// if there's no change, don't do anything
if
(
input
===
previousInput
)
{
return
}
previousInput
=
input
// fire storage update
// NOTE: save at most once per 5 seconds
if
(
saveTimeout
)
{
window
.
clearTimeout
(
saveTimeout
)
}
saveTimeout
=
window
.
setTimeout
(()
=>
{
fileManager
.
saveCurrentFile
()
},
5000
)
}
// auto save the file when content changed
editor
.
event
.
register
(
'contentChanged'
,
editorOnChange
)
// save the file when switching
editor
.
event
.
register
(
'sessionSwitched'
,
editorOnChange
)
executionContext
.
event
.
register
(
'contextChanged'
,
this
,
function
(
context
)
{
executionContext
.
event
.
register
(
'contextChanged'
,
this
,
function
(
context
)
{
self
.
runCompiler
()
self
.
runCompiler
()
...
@@ -533,7 +501,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
...
@@ -533,7 +501,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// check init query parameters from the URL once the compiler is loaded
// check init query parameters from the URL once the compiler is loaded
self
.
_components
.
compiler
.
event
.
register
(
'compilerLoaded'
,
this
,
function
(
version
)
{
self
.
_components
.
compiler
.
event
.
register
(
'compilerLoaded'
,
this
,
function
(
version
)
{
previousInput
=
''
self
.
runCompiler
()
self
.
runCompiler
()
if
(
queryParams
.
get
().
context
)
{
if
(
queryParams
.
get
().
context
)
{
...
...
src/app/editor/editor.js
View file @
d33aa9fe
...
@@ -7,6 +7,8 @@ var ace = require('brace')
...
@@ -7,6 +7,8 @@ var ace = require('brace')
require
(
'brace/theme/tomorrow_night_blue'
)
require
(
'brace/theme/tomorrow_night_blue'
)
var
globalRegistry
=
require
(
'../../global/registry'
)
var
Range
=
ace
.
acequire
(
'ace/range'
).
Range
var
Range
=
ace
.
acequire
(
'ace/range'
).
Range
require
(
'brace/ext/language_tools'
)
require
(
'brace/ext/language_tools'
)
require
(
'brace/ext/searchbox'
)
require
(
'brace/ext/searchbox'
)
...
@@ -63,13 +65,19 @@ document.head.appendChild(yo`
...
@@ -63,13 +65,19 @@ document.head.appendChild(yo`
</style>
</style>
`
)
`
)
function
Editor
(
opts
=
{})
{
function
Editor
(
opts
=
{}
,
localRegistry
)
{
var
self
=
this
var
self
=
this
var
el
=
yo
`<div id="input"></div>`
var
el
=
yo
`<div id="input"></div>`
var
editor
=
ace
.
edit
(
el
)
var
editor
=
ace
.
edit
(
el
)
if
(
styles
.
appProperties
.
aceTheme
)
{
if
(
styles
.
appProperties
.
aceTheme
)
{
editor
.
setTheme
(
'ace/theme/'
+
styles
.
appProperties
.
aceTheme
)
editor
.
setTheme
(
'ace/theme/'
+
styles
.
appProperties
.
aceTheme
)
}
}
self
.
_components
=
{}
self
.
_components
.
registry
=
localRegistry
||
globalRegistry
self
.
_deps
=
{
fileManager
:
self
.
_components
.
registry
.
get
(
'filemanager'
).
api
,
config
:
self
.
_components
.
registry
.
get
(
'config'
).
api
}
ace
.
acequire
(
'ace/ext/language_tools'
)
ace
.
acequire
(
'ace/ext/language_tools'
)
editor
.
setOptions
({
editor
.
setOptions
({
...
@@ -275,11 +283,15 @@ function Editor (opts = {}) {
...
@@ -275,11 +283,15 @@ function Editor (opts = {}) {
this
.
find
=
(
string
)
=>
editor
.
find
(
string
)
this
.
find
=
(
string
)
=>
editor
.
find
(
string
)
this
.
previousInput
=
''
this
.
saveTimeout
=
null
// Do setup on initialisation here
// Do setup on initialisation here
editor
.
on
(
'changeSession'
,
function
()
{
editor
.
on
(
'changeSession'
,
function
()
{
editorOnChange
(
self
)
event
.
trigger
(
'sessionSwitched'
,
[])
event
.
trigger
(
'sessionSwitched'
,
[])
editor
.
getSession
().
on
(
'change'
,
function
()
{
editor
.
getSession
().
on
(
'change'
,
function
()
{
editorOnChange
(
self
)
event
.
trigger
(
'contentChanged'
,
[])
event
.
trigger
(
'contentChanged'
,
[])
})
})
})
})
...
@@ -290,4 +302,29 @@ function Editor (opts = {}) {
...
@@ -290,4 +302,29 @@ function Editor (opts = {}) {
editor
.
resize
(
true
)
editor
.
resize
(
true
)
}
}
function
editorOnChange
(
self
)
{
var
currentFile
=
self
.
_deps
.
config
.
get
(
'currentFile'
)
if
(
!
currentFile
)
{
return
}
var
input
=
self
.
get
(
currentFile
)
if
(
!
input
)
{
return
}
// if there's no change, don't do anything
if
(
input
===
self
.
previousInput
)
{
return
}
self
.
previousInput
=
input
// fire storage update
// NOTE: save at most once per 5 seconds
if
(
self
.
saveTimeout
)
{
window
.
clearTimeout
(
self
.
saveTimeout
)
}
self
.
saveTimeout
=
window
.
setTimeout
(()
=>
{
self
.
_deps
.
fileManager
.
saveCurrentFile
()
},
5000
)
}
module
.
exports
=
Editor
module
.
exports
=
Editor
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment