-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
31 lines (23 loc) · 759 Bytes
/
Copy pathmain.js
File metadata and controls
31 lines (23 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var currentSource;
var currentPage;
var cs = require('content-studio');
var actions = require('actions');
// Store the current editor in a variable for when someone
// hits "ctrl+u"
cs.on('editor-active', function(editorcontrol) {
currentPage = editorcontrol.uri;
});
var viewSourceAction = actions.createAction('View Source', 'shortcut U');
actions.addAction(viewSourceAction, 'tools');
viewSourceAction.on('action', function() {
if (currentSource) {
// remove the current "view source" tab to avoid 1000s of view
// source pinned tabs...
cs.removeTab(currentSource);
}
if (currentPage) {
// When tabs are created with a URI, a web view is opened with it.
cs.createTab(currentPage);
}
currentSource = currentPage;
});