-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
46 lines (40 loc) · 1.14 KB
/
index.js
File metadata and controls
46 lines (40 loc) · 1.14 KB
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
import osjs from 'osjs';
import {name as applicationName} from './metadata.json';
import React from 'react';
import ReactDOM from 'react-dom';
import App from './src';
const register = (core, args, options, metadata) => {
const proc = core.make('osjs/application', {args, options, metadata});
const win = proc.createWindow({
id: 'OfficeApplicationWindow',
title: core.make('osjs/locale').translatableFlat(proc.metadata.title),
icon: proc.resource(metadata.icon),
dimension: {width: 350, height: 400},
position: {left: 700, top: 200},
attributes: {
minDimension: {width: 350, height: 400},
sessionable: true,
},
});
const setWindowState = () => {
if (window.innerWidth < 640) {
win.maximize();
} else {
win.restore();
}
};
window.addEventListener('resize', setWindowState);
win.on('render', () => {
setWindowState();
win.focus();
});
win.render(($content) => {
ReactDOM.render(
<App core={core} win={win} proc={proc} data={args.file} />,
$content
);
});
win.once('render', () => win.focus());
return proc;
};
osjs.register(applicationName, register);