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
b5d9dc3c
Commit
b5d9dc3c
authored
Feb 01, 2019
by
Grandschtroumpf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Format for linter
parent
e4430efb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
27 deletions
+27
-27
editor.js
src/app/editor/editor.js
+27
-27
No files found.
src/app/editor/editor.js
View file @
b5d9dc3c
...
@@ -20,7 +20,7 @@ require('brace/mode/json')
...
@@ -20,7 +20,7 @@ require('brace/mode/json')
const
styleGuide
=
require
(
'../ui/styles-guide/theme-chooser'
)
const
styleGuide
=
require
(
'../ui/styles-guide/theme-chooser'
)
const
styles
=
styleGuide
.
chooser
()
const
styles
=
styleGuide
.
chooser
()
function
setTheme
(
cb
)
{
function
setTheme
(
cb
)
{
if
(
styles
.
appProperties
.
aceTheme
)
{
if
(
styles
.
appProperties
.
aceTheme
)
{
cb
(
'brace/theme/'
,
styles
.
appProperties
.
aceTheme
)
cb
(
'brace/theme/'
,
styles
.
appProperties
.
aceTheme
)
}
}
...
@@ -96,7 +96,7 @@ class Editor {
...
@@ -96,7 +96,7 @@ class Editor {
emptySession
emptySession
*/
*/
constructor
(
opts
=
{},
localRegistry
)
{
constructor
(
opts
=
{},
localRegistry
)
{
// Dependancies
// Dependancies
this
.
_components
=
{}
this
.
_components
=
{}
this
.
_components
.
registry
=
localRegistry
||
globalRegistry
this
.
_components
.
registry
=
localRegistry
||
globalRegistry
...
@@ -190,7 +190,7 @@ class Editor {
...
@@ -190,7 +190,7 @@ class Editor {
})
})
}
}
_onChange
()
{
_onChange
()
{
const
currentFile
=
this
.
_deps
.
config
.
get
(
'currentFile'
)
const
currentFile
=
this
.
_deps
.
config
.
get
(
'currentFile'
)
if
(
!
currentFile
)
{
if
(
!
currentFile
)
{
return
return
...
@@ -215,7 +215,7 @@ class Editor {
...
@@ -215,7 +215,7 @@ class Editor {
},
5000
)
},
5000
)
}
}
_switchSession
(
path
)
{
_switchSession
(
path
)
{
this
.
currentSession
=
path
this
.
currentSession
=
path
this
.
editor
.
setSession
(
this
.
sessions
[
this
.
currentSession
])
this
.
editor
.
setSession
(
this
.
sessions
[
this
.
currentSession
])
this
.
editor
.
setReadOnly
(
this
.
readOnlySessions
[
this
.
currentSession
])
this
.
editor
.
setReadOnly
(
this
.
readOnlySessions
[
this
.
currentSession
])
...
@@ -226,7 +226,7 @@ class Editor {
...
@@ -226,7 +226,7 @@ class Editor {
* Get Ace mode base of the extension of the session file
* Get Ace mode base of the extension of the session file
* @param {string} path Path of the file
* @param {string} path Path of the file
*/
*/
_getMode
(
path
)
{
_getMode
(
path
)
{
let
ext
=
path
.
indexOf
(
'.'
)
!==
-
1
?
/
[^
.
]
+$/
.
exec
(
path
)
:
null
let
ext
=
path
.
indexOf
(
'.'
)
!==
-
1
?
/
[^
.
]
+$/
.
exec
(
path
)
:
null
if
(
ext
)
ext
=
ext
[
0
]
if
(
ext
)
ext
=
ext
[
0
]
return
ext
&&
this
.
modes
[
ext
]
?
this
.
modes
[
ext
]
:
this
.
modes
[
'txt'
]
return
ext
&&
this
.
modes
[
ext
]
?
this
.
modes
[
ext
]
:
this
.
modes
[
'txt'
]
...
@@ -237,7 +237,7 @@ class Editor {
...
@@ -237,7 +237,7 @@ class Editor {
* @param {string} content Content of the file to open
* @param {string} content Content of the file to open
* @param {string} mode Ace Mode for this file [Default is `text`]
* @param {string} mode Ace Mode for this file [Default is `text`]
*/
*/
_createSession
(
content
,
mode
)
{
_createSession
(
content
,
mode
)
{
const
s
=
new
ace
.
EditSession
(
content
)
const
s
=
new
ace
.
EditSession
(
content
)
s
.
setMode
(
mode
||
'ace/mode/text'
)
s
.
setMode
(
mode
||
'ace/mode/text'
)
s
.
setUndoManager
(
new
ace
.
UndoManager
())
s
.
setUndoManager
(
new
ace
.
UndoManager
())
...
@@ -250,14 +250,14 @@ class Editor {
...
@@ -250,14 +250,14 @@ class Editor {
* Attempts to find the string in the current document
* Attempts to find the string in the current document
* @param {string} string
* @param {string} string
*/
*/
find
(
string
)
{
find
(
string
)
{
return
this
.
editor
.
find
(
string
)
return
this
.
editor
.
find
(
string
)
}
}
/**
/**
* Display an Empty read-only session
* Display an Empty read-only session
*/
*/
displayEmptyReadOnlySession
()
{
displayEmptyReadOnlySession
()
{
this
.
currentSession
=
null
this
.
currentSession
=
null
this
.
editor
.
setSession
(
this
.
emptySession
)
this
.
editor
.
setSession
(
this
.
emptySession
)
this
.
editor
.
setReadOnly
(
true
)
this
.
editor
.
setReadOnly
(
true
)
...
@@ -268,7 +268,7 @@ class Editor {
...
@@ -268,7 +268,7 @@ class Editor {
* @param {number} row Line index of the breakpoint
* @param {number} row Line index of the breakpoint
* @param {string} className Class of the breakpoint
* @param {string} className Class of the breakpoint
*/
*/
setBreakpoint
(
row
,
className
)
{
setBreakpoint
(
row
,
className
)
{
this
.
editor
.
session
.
setBreakpoint
(
row
,
className
)
this
.
editor
.
session
.
setBreakpoint
(
row
,
className
)
}
}
...
@@ -276,7 +276,7 @@ class Editor {
...
@@ -276,7 +276,7 @@ class Editor {
* Increment the font size (in pixels) for the editor text.
* Increment the font size (in pixels) for the editor text.
* @param {number} incr The amount of pixels to add to the font.
* @param {number} incr The amount of pixels to add to the font.
*/
*/
editorFontSize
(
incr
)
{
editorFontSize
(
incr
)
{
this
.
editor
.
setFontSize
(
this
.
editor
.
getFontSize
()
+
incr
)
this
.
editor
.
setFontSize
(
this
.
editor
.
getFontSize
()
+
incr
)
}
}
...
@@ -284,7 +284,7 @@ class Editor {
...
@@ -284,7 +284,7 @@ class Editor {
* Set the text in the current session, if any.
* Set the text in the current session, if any.
* @param {string} text New text to be place.
* @param {string} text New text to be place.
*/
*/
setText
(
text
)
{
setText
(
text
)
{
if
(
this
.
currentSession
&&
this
.
sessions
[
this
.
currentSession
])
{
if
(
this
.
currentSession
&&
this
.
sessions
[
this
.
currentSession
])
{
this
.
sessions
[
this
.
currentSession
].
setValue
(
text
)
this
.
sessions
[
this
.
currentSession
].
setValue
(
text
)
}
}
...
@@ -295,7 +295,7 @@ class Editor {
...
@@ -295,7 +295,7 @@ class Editor {
* @param {string} path Path of the session to open.
* @param {string} path Path of the session to open.
* @param {string} content Content of the document or update.
* @param {string} content Content of the document or update.
*/
*/
open
(
path
,
content
)
{
open
(
path
,
content
)
{
if
(
!
this
.
sessions
[
path
])
{
if
(
!
this
.
sessions
[
path
])
{
const
session
=
this
.
_createSession
(
content
,
this
.
_getMode
(
path
))
const
session
=
this
.
_createSession
(
content
,
this
.
_getMode
(
path
))
this
.
sessions
[
path
]
=
session
this
.
sessions
[
path
]
=
session
...
@@ -311,7 +311,7 @@ class Editor {
...
@@ -311,7 +311,7 @@ class Editor {
* @param {string} path Path of the session to open.
* @param {string} path Path of the session to open.
* @param {string} content Content of the document or update.
* @param {string} content Content of the document or update.
*/
*/
openReadOnly
(
path
,
content
)
{
openReadOnly
(
path
,
content
)
{
if
(
!
this
.
sessions
[
path
])
{
if
(
!
this
.
sessions
[
path
])
{
const
session
=
this
.
_createSession
(
content
,
this
.
_getMode
(
path
))
const
session
=
this
.
_createSession
(
content
,
this
.
_getMode
(
path
))
this
.
sessions
[
path
]
=
session
this
.
sessions
[
path
]
=
session
...
@@ -324,7 +324,7 @@ class Editor {
...
@@ -324,7 +324,7 @@ class Editor {
* Content of the current session
* Content of the current session
* @return {String} content of the file referenced by @arg path
* @return {String} content of the file referenced by @arg path
*/
*/
currentContent
()
{
currentContent
()
{
return
this
.
get
(
this
.
current
())
return
this
.
get
(
this
.
current
())
}
}
...
@@ -334,7 +334,7 @@ class Editor {
...
@@ -334,7 +334,7 @@ class Editor {
* @param {string} path Path of the session to get.
* @param {string} path Path of the session to get.
* @return {String} content of the file referenced by @arg path
* @return {String} content of the file referenced by @arg path
*/
*/
get
(
path
)
{
get
(
path
)
{
if
(
!
path
||
this
.
currentSession
===
path
)
{
if
(
!
path
||
this
.
currentSession
===
path
)
{
return
this
.
editor
.
getValue
()
return
this
.
editor
.
getValue
()
}
else
if
(
this
.
sessions
[
path
])
{
}
else
if
(
this
.
sessions
[
path
])
{
...
@@ -347,7 +347,7 @@ class Editor {
...
@@ -347,7 +347,7 @@ class Editor {
* returns `undefined` if no session is being editer
* returns `undefined` if no session is being editer
* @return {String} path of the current session
* @return {String} path of the current session
*/
*/
current
()
{
current
()
{
if
(
this
.
editor
.
getSession
()
===
this
.
emptySession
)
{
if
(
this
.
editor
.
getSession
()
===
this
.
emptySession
)
{
return
return
}
}
...
@@ -357,7 +357,7 @@ class Editor {
...
@@ -357,7 +357,7 @@ class Editor {
/**
/**
* The position of the cursor
* The position of the cursor
*/
*/
getCursorPosition
()
{
getCursorPosition
()
{
return
this
.
editor
.
session
.
doc
.
positionToIndex
(
return
this
.
editor
.
session
.
doc
.
positionToIndex
(
this
.
editor
.
getCursorPosition
(),
this
.
editor
.
getCursorPosition
(),
0
0
...
@@ -367,7 +367,7 @@ class Editor {
...
@@ -367,7 +367,7 @@ class Editor {
/**
/**
* Remove the current session from the list of sessions.
* Remove the current session from the list of sessions.
*/
*/
discardCurrentSession
()
{
discardCurrentSession
()
{
if
(
this
.
sessions
[
this
.
currentSession
])
{
if
(
this
.
sessions
[
this
.
currentSession
])
{
delete
this
.
sessions
[
this
.
currentSession
]
delete
this
.
sessions
[
this
.
currentSession
]
this
.
currentSession
=
null
this
.
currentSession
=
null
...
@@ -378,7 +378,7 @@ class Editor {
...
@@ -378,7 +378,7 @@ class Editor {
* Remove a session based on its path.
* Remove a session based on its path.
* @param {string} path
* @param {string} path
*/
*/
discard
(
path
)
{
discard
(
path
)
{
if
(
this
.
sessions
[
path
])
delete
this
.
sessions
[
path
]
if
(
this
.
sessions
[
path
])
delete
this
.
sessions
[
path
]
if
(
this
.
currentSession
===
path
)
this
.
currentSession
=
null
if
(
this
.
currentSession
===
path
)
this
.
currentSession
=
null
}
}
...
@@ -387,7 +387,7 @@ class Editor {
...
@@ -387,7 +387,7 @@ class Editor {
* Resize the editor, and sets whether or not line wrapping is enabled.
* Resize the editor, and sets whether or not line wrapping is enabled.
* @param {boolean} useWrapMode Enable (or disable) wrap mode
* @param {boolean} useWrapMode Enable (or disable) wrap mode
*/
*/
resize
(
useWrapMode
)
{
resize
(
useWrapMode
)
{
this
.
editor
.
resize
()
this
.
editor
.
resize
()
const
session
=
this
.
editor
.
getSession
()
const
session
=
this
.
editor
.
getSession
()
session
.
setUseWrapMode
(
useWrapMode
)
session
.
setUseWrapMode
(
useWrapMode
)
...
@@ -409,7 +409,7 @@ class Editor {
...
@@ -409,7 +409,7 @@ class Editor {
* @param {string} source Path of the session to add the mark on.
* @param {string} source Path of the session to add the mark on.
* @param {string} cssClass css to apply to the mark.
* @param {string} cssClass css to apply to the mark.
*/
*/
addMarker
(
lineColumnPos
,
source
,
cssClass
)
{
addMarker
(
lineColumnPos
,
source
,
cssClass
)
{
const
currentRange
=
new
Range
(
const
currentRange
=
new
Range
(
lineColumnPos
.
start
.
line
,
lineColumnPos
.
start
.
line
,
lineColumnPos
.
start
.
column
,
lineColumnPos
.
start
.
column
,
...
@@ -429,7 +429,7 @@ class Editor {
...
@@ -429,7 +429,7 @@ class Editor {
* @param {boolean} animate If true animates scrolling
* @param {boolean} animate If true animates scrolling
* @param {Function} callback Function to be called when the animation has finished
* @param {Function} callback Function to be called when the animation has finished
*/
*/
scrollToLine
(
line
,
center
,
animate
,
callback
)
{
scrollToLine
(
line
,
center
,
animate
,
callback
)
{
this
.
editor
.
scrollToLine
(
line
,
center
,
animate
,
callback
)
this
.
editor
.
scrollToLine
(
line
,
center
,
animate
,
callback
)
}
}
...
@@ -438,7 +438,7 @@ class Editor {
...
@@ -438,7 +438,7 @@ class Editor {
* @param {string} markerId Id of the marker
* @param {string} markerId Id of the marker
* @param {string} source Path of the session
* @param {string} source Path of the session
*/
*/
removeMarker
(
markerId
,
source
)
{
removeMarker
(
markerId
,
source
)
{
if
(
this
.
sessions
[
source
])
{
if
(
this
.
sessions
[
source
])
{
this
.
sessions
[
source
].
removeMarker
(
markerId
)
this
.
sessions
[
source
].
removeMarker
(
markerId
)
}
}
...
@@ -447,7 +447,7 @@ class Editor {
...
@@ -447,7 +447,7 @@ class Editor {
/**
/**
* Clears all the annotations for the current session.
* Clears all the annotations for the current session.
*/
*/
clearAnnotations
()
{
clearAnnotations
()
{
this
.
sourceAnnotations
=
[]
this
.
sourceAnnotations
=
[]
this
.
editor
.
getSession
().
clearAnnotations
()
this
.
editor
.
getSession
().
clearAnnotations
()
}
}
...
@@ -456,7 +456,7 @@ class Editor {
...
@@ -456,7 +456,7 @@ class Editor {
* Add an annotation to the current session.
* Add an annotation to the current session.
* @param {Object} annotation
* @param {Object} annotation
*/
*/
addAnnotation
(
annotation
)
{
addAnnotation
(
annotation
)
{
this
.
sourceAnnotations
[
this
.
sourceAnnotations
.
length
]
=
annotation
this
.
sourceAnnotations
[
this
.
sourceAnnotations
.
length
]
=
annotation
this
.
setAnnotations
(
this
.
sourceAnnotations
)
this
.
setAnnotations
(
this
.
sourceAnnotations
)
}
}
...
@@ -465,7 +465,7 @@ class Editor {
...
@@ -465,7 +465,7 @@ class Editor {
* Set a list of annotations to the current session.
* Set a list of annotations to the current session.
* @param {Array<Object>} annotation
* @param {Array<Object>} annotation
*/
*/
setAnnotations
(
sourceAnnotations
)
{
setAnnotations
(
sourceAnnotations
)
{
this
.
editor
.
getSession
().
setAnnotations
(
sourceAnnotations
)
this
.
editor
.
getSession
().
setAnnotations
(
sourceAnnotations
)
}
}
...
@@ -474,7 +474,7 @@ class Editor {
...
@@ -474,7 +474,7 @@ class Editor {
* @param {number} line
* @param {number} line
* @param {number} col
* @param {number} col
*/
*/
gotoLine
(
line
,
col
)
{
gotoLine
(
line
,
col
)
{
this
.
editor
.
focus
()
this
.
editor
.
focus
()
this
.
editor
.
gotoLine
(
line
+
1
,
col
-
1
,
true
)
this
.
editor
.
gotoLine
(
line
+
1
,
col
-
1
,
true
)
}
}
...
...
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