-
Notifications
You must be signed in to change notification settings - Fork 317
/
Copy pathContentOpenWith.js
55 lines (50 loc) · 1.45 KB
/
ContentOpenWith.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
/**
* @flow
* @file Base class for the Open With ES6 wrapper
* @author Box
*/
import 'regenerator-runtime/runtime';
import * as React from 'react';
// TODO switch to createRoot when upgrading to React 18
// eslint-disable-next-line react/no-deprecated
import { render } from 'react-dom';
import ES6Wrapper from './ES6Wrapper';
import ContentOpenWithReactComponent from '../content-open-with';
class ContentOpenWith extends ES6Wrapper {
/**
* Callback for executing an integration
*
* @return {void}
*/
onExecute = (appIntegrationId: string): void => {
this.emit('execute', appIntegrationId);
};
/**
* Callback when an error occurs while loading or executing integrations
*
* @return {void}
*/
onError = (error: Error): void => {
this.emit('error', error);
};
/** @inheritdoc */
render() {
render(
<ContentOpenWithReactComponent
componentRef={this.setComponent}
fileId={this.id}
language={this.language}
messages={this.messages}
onError={this.onError}
onExecute={this.onExecute}
onInteraction={this.onInteraction}
token={this.token}
{...this.options}
/>,
this.container,
);
}
}
global.Box = global.Box || {};
global.Box.ContentOpenWith = ContentOpenWith;
export default ContentOpenWith;