-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenderer.js
65 lines (58 loc) · 2.12 KB
/
renderer.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const React = require('react');
const ReactDOM = require('react-dom');
const config = require('./configs/config');
const GoldenLayout = require('golden-layout');
let mainLayout;
//* TODO: ADD LET SO IT IS NOT A GLOBAL ON PROD
//* terminals object holds all components and its all info. It is global for dev
const terminals = {};
const componentConfigs = [];
const addMenuItem = (title, componentName, state = '', type = 'component') => {
const element = $('<li>' + title + '</li>');
$('#newItemMenu ul').append(element);
const newItemConfig = {
title : title,
type : type,
componentName : componentName,
componentState: state,
component : (
type = 'react-component'
? componentName
: undefined
)
};
mainLayout.createDragSource(element, newItemConfig);
componentConfigs.push(newItemConfig);
};
document.addEventListener('DOMContentLoaded', async ev => {
require('./common/inactiveStateStyle');
mainLayout = new GoldenLayout(require('./configs/mainLayout'), document.querySelector('#mainLayout'));
require('./components/xterm');
require('./components/monaco');
require('./components/palette');
// require( './components/filemanager' );
require('./common/keyboard');
// Make New item menu appear whenever there are no components. Make it disappear whenever there is at least one.
mainLayout.on('initialised', ev => {
//TODO: New Item Menu toggling should be exported in dedicated module.
if (mainLayout.root.getItemsByType('component').length === 0)
document.querySelector('#newItemMenu').style.display = 'block';
}
);
mainLayout.on('stateChanged', ev => {
console.log('state changed', ev);
if (mainLayout.root.getItemsByType('component').length === 0)
document.querySelector('#newItemMenu').style.display = 'block';
else
document.querySelector('#newItemMenu').style.display = 'none';
}
);
mainLayout.on('stackCreated', ev => {
if (ev.parent.isStack === true)
ev.parent.on('activeContentItemChanged', e => {
console.log('active changed', e);
});
}
);
mainLayout.init();
});