Module Editor
Page Level Editor
Properties
assetdb AssetDB
The AssetDB instance
App Object
The Editor.App is your app.js module. Read more details in Define your application.
name String
The name of your app. It is defined in the name
field in package.json
version String
your app version
path String
The current app.js running directory.
home String
Your application's data path. Usually it is ~/.{your-app-name}
extend Function
Extends Editor.App
versions Object
versions of your app and submodules
frameworkPath String
The editor framework module path. Usually it is {your-app}/editor-framework/
Methods
log
(
-
[args
]
)
- [args ]
Log the normal message and show on the console.
The method will send ipc message console:log
to all windows.
name | type | description |
---|---|---|
args
optional
|
... |
whatever arguments the message needs |
success
(
-
[args
]
)
- [args ]
Log the success message and show on the console
The method will send ipc message console:success
to all windows.
name | type | description |
---|---|---|
args
optional
|
... |
whatever arguments the message needs |
failed
(
-
[args
]
)
- [args ]
Log the failed message and show on the console
The method will send ipc message console:failed
to all windows.
name | type | description |
---|---|---|
args
optional
|
... |
whatever arguments the message needs |
info
(
-
[args
]
)
- [args ]
Log the info message and show on the console
The method will send ipc message console:info
to all windows.
name | type | description |
---|---|---|
args
optional
|
... |
whatever arguments the message needs |
warn
(
-
[args
]
)
- [args ]
Log the warnning message and show on the console,
it also shows the call stack start from the function call it.
The method will send ipc message console:warn
to all windows.
name | type | description |
---|---|---|
args
optional
|
... |
whatever arguments the message needs |
error
(
-
[args
]
)
- [args ]
Log the error message and show on the console,
it also shows the call stack start from the function call it.
The method will sends ipc message console:error
to all windows.
name | type | description |
---|---|---|
args
optional
|
... |
whatever arguments the message needs |
fatal
(
-
[args
]
)
- [args ]
Log the fatal message and show on the console, the app will quit immediately after that.
name | type | description |
---|---|---|
args
optional
|
... |
whatever arguments the message needs |
connectToConsole ( )
Connect to console panel. Once the console connected, all logs will kept in core-level
and display
on the console panel in page-level
.
clearLog ( )
Clear the logs
loadProfile
(
-
name
-
type
-
defaultProfile
)
object
- name
- type
- defaultProfile
Load profile via name
and type
, if no profile found, it will use the defaultProfile
and save it to the disk.
You must register your profile path with type
via {@link Editor.registerProfilePath} before you
can use it. The Editor Framework will search a profile under your register path with the name
.
name | type | description |
---|---|---|
name
|
string |
The name of the profile. |
type
|
string |
The type of the profile, make sure you register the type via {@link Editor.registerProfilePath}. |
defaultProfile
|
object |
The default profile to use if the profile is not found. |
returns:
A profile object with two additional function: - save: save the profile. - clear: clear all properties in the profile.
examples:
// register a project profile
Editor.registerProfilePath( 'project', '~/foo/bar');
// load the profile at ~/foo/bar/foobar.json
let foobarProfile = Editor.loadProfile( 'foobar', 'project', {
foo: 'foo',
bar: 'bar',
});
// change and save your profile
foobarProfile.foo = 'hello foo';
foobarProfile.save();
loadAllPackages ( )
Search and load all packages from the path you registerred Editor.registerPackagePath
require
(
-
url
)
- url
Require module through url path
name | type | description |
---|---|---|
url
|
string |
execSpawn
(
-
command
-
options
)
- command
- options
watchPackages ( )
Watch packages
registerProfilePath
(
-
type
-
path
)
- type
- path
registerDefaultLayout
(
-
path
)
- path
Register a path, when loading packages, it will search the path you registerred. Editor.loadPackages
name | type | description |
---|---|---|
path
|
string |
A absolute path for searching your packages. |
init
(
-
opts
-
profile
-
package-search-path
-
main-menu
-
panel-window
-
layout
-
selection
-
i18n
)
- opts
- profile
- package-search-path
- main-menu
- panel-window
- layout
- selection
- i18n
init editor during App.init
name | type | description |
---|---|---|
opts
|
object |
options |
profile
|
object |
profile type to path |
package-search-path
|
array |
package search path |
main-menu
|
function |
a function return the new main-menu template |
panel-window
|
string |
panel window url |
layout
|
string |
default layout file |
selection
|
array |
selection type |
i18n
|
array |
i18n phrases |
reset ( )
reset editor
sendToWindowsExclude
(
-
channel
-
[args
]
-
excluded
)
- channel
- [args ]
- excluded
Send args...
to windows except the excluded
name | type | description |
---|---|---|
channel
|
string | |
args
optional
|
... |
whatever arguments the message needs |
excluded
|
object |
A WebContents object. |
sendToWindows
(
-
channel
-
[args
]
)
- channel
- [args ]
Send args...
to all opened windows via channel
in asynchronous message. The page-level
can handle it by listening to the channel event of the ipc module.
name | type | description |
---|---|---|
channel
|
string | |
args
optional
|
... |
whatever arguments the message needs |
examples:
In core-level
:
`
js
Editor.sendToWindows('foo:bar', 'Hello World!');
In page-level
:
// index.html
sendToCore
(
-
channel
-
[args
]
)
- channel
- [args ]
Send args...
to core itself via channel
in asynchronous message.
name | type | description |
---|---|---|
channel
|
string | |
args
optional
|
... |
whatever arguments the message needs |
sendToAll
(
-
channel
-
[args
]
)
- channel
- [args ]
Send args...
to all opened window and core via channel
in asynchronous message.
name | type | description |
---|---|---|
channel
|
string | |
args
optional
|
... |
whatever arguments the message needs |
sendToPanel
(
-
panelID
-
channel
-
[args
]
)
- panelID
- channel
- [args ]
sendToMainWindow
(
-
channel
-
[args
]
)
- channel
- [args ]
Send args...
to main window via channel
in asynchronous message.
name | type | description |
---|---|---|
channel
|
string | |
args
optional
|
... |
whatever arguments the message needs |
url
(
-
url
)
- url
Convert a url by its protocol to a filesystem path. This function is useful when you try to
get some internal file. You can use {@link Editor.registerProtocol} to register and map your filesystem
path to url. By default, Editor Framework register editor-framework://
and app://
protocol.
name | type | description |
---|---|---|
url
|
string |
examples:
// it will return "{your-app-path}/foobar/foobar.js"
Editor.url('app://foobar/foobar.js');
registerProtocol
(
-
protocol
-
fn
)
- protocol
- fn
Register a protocol so that {@link Editor.url} can use it to convert an url to the filesystem path.
The fn
accept an url Object via url.parse
examples:
const Path = require('path');
let _url2path = base => {
return urlInfo => {
if ( urlInfo.pathname ) {
return Path.join( base, urlInfo.host, urlInfo.pathname );
}
return Path.join( base, urlInfo.host );
};
};
Editor.registerProtocol('editor-framework', _url2path(Editor.frameworkPath));
require
(
-
url
)
- url
Require module through url path
name | type | description |
---|---|---|
url
|
string |
log
(
-
[arg
]
)
- [arg ]
Log the normal message and show on the console.
The method will send ipc message console:log
to core.
name | type | description |
---|---|---|
arg
optional
|
... |
whatever arguments the message needs |
sendToCoreSync
(
-
message
-
[arg
]
)
Unknown
- message
- [arg ]
Send message to core-level synchronized and return a result which is responded from core-level
name | type | description |
---|---|---|
message
|
string |
the message to send |
arg
optional
|
... |
whatever arguments the message needs |
returns:
results
sendToCore
(
-
message
-
[arg
]
)
- message
- [arg ]
Send message to editor-core, which is so called as main app, or atom shell's browser side.
name | type | description |
---|---|---|
message
|
string |
the message to send |
arg
optional
|
... |
whatever arguments the message needs |
sendToWindows
(
-
message
-
[arg
]
-
[options
]
)
- message
- [arg ]
- [options ]
Broadcast message to all pages. The page is so called as atom shell's web side. Each application window is an independent page and has its own JavaScript context.
sendToMainWindow
(
-
message
-
[arg
]
)
- message
- [arg ]
Broadcast message to main page. The page is so called as atom shell's web side. Each application window is an independent page and has its own JavaScript context.
name | type | description |
---|---|---|
message
|
string |
the message to send |
arg
optional
|
... |
whatever arguments the message needs |
sendToAll
(
-
message
-
[arg
]
-
[options
]
)
- message
- [arg ]
- [options ]
sendToPanel
(
-
panelID
-
message
-
[arg
]
)
- panelID
- message
- [arg ]
sendRequestToCore
(
-
channel
-
[arg
]
-
reply
)
number
- channel
- [arg ]
- reply
Send args...
to core via channel
in asynchronous message, and waiting for the core-level
to reply the message through callback
.
name | type | description |
---|---|---|
channel
|
string |
the request message channel |
arg
optional
|
... |
whatever arguments the request needs |
reply
|
function |
the callback used to handle replied arguments |
returns:
cancelRequestToCore ( )
Cancel request sent to core by sessionId
waitForReply
(
-
channel
-
[arg
]
-
reply
-
[timeout
]
)
number
- channel
- [arg ]
- reply
- [timeout ]
Send args...
to core via channel
in asynchronous message, and waiting for reply
to reply the message through callback
.
name | type | description |
---|---|---|
channel
|
string |
the request message channel |
arg
optional
|
... |
whatever arguments the request needs |
reply
|
function |
the callback used to handle replied arguments |
timeout
optional
|
number |
timeout for the reply, if timeout = -1, it will never get expired |
returns:
cancelWaitForReply ( )
Cancel wait for reply by channel and sessionId