You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A React wrapper for [NMRium](https://www.nmrium.org/) that is already used in [nmrXiv](https://nmrxiv.org/) and [Chemotion](https://www.chemotion.net/), and we recommend to use it with any platform embedding [NMRium](https://www.nmrium.org/)
- Start the development server by opening a new terminal and running:
68
+
69
+
```bash
70
+
npm run build
71
+
```
72
+
73
+
The production server will run on localhost:1337.
74
+
75
+
## Wrapper Events
76
+
NMRium wrapper uses a custom event to handle the communication between NMRium and the parent application, for that we create [MessageEvent](https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent)s by using a [window interface](https://developer.mozilla.org/en-US/docs/Web/API/Window). We provide two events helper functions in /src/events/event.ts, which you can use by importing events
You can pass NMRium data that you get when you export the data from the NMRium or what you received from dataChange event
126
+
```ts
127
+
events.trigger('load', {
128
+
data: {
129
+
spectra:[
130
+
source:{
131
+
jcampURL:""
132
+
}
133
+
]
134
+
},
135
+
type:"nmrium"
136
+
}
137
+
);
138
+
```
23
139
24
-
```docker-compose stop```
140
+
#### Error handler example:
25
141
26
-
### production build
142
+
```ts
143
+
events.on('error', (error)=>{
144
+
// you code here
145
+
});
146
+
```
147
+
148
+
#### Data change hander example:
149
+
150
+
```ts
151
+
events.on('dataChange', (data)=>{
152
+
// you code here
153
+
});
154
+
```
155
+
156
+
## Contribution
157
+
### Contribute to The Code
158
+
-**Branching**: Create a new branch from the`development`. The branch name should be all small with words separated by a hyphen.
159
+
-**Pull requests**: Pull requests should go towards (also known as a PR) to the `development` branch. Please link the issues which the pull request solves ti it. Finally, assign a reviewer.
160
+
-**Delete the stale branch**: After your branch is merged and the pull request is closed, please don't forget to delete your stale branch.
161
+
162
+
### Contributors
163
+
- Hamed Musallam
164
+
- Lan Bao Quang Le
165
+
- Nisha Sharma
166
+
- Noura Rayya
167
+
- Venkata chandrasekhar Nainala (Chandu)
168
+
169
+
170
+
## Versions Details
171
+
Current NMRium version: 0.33.0
172
+
173
+
## Relevant Links
174
+
Here you can find the links to NMRium and all the repositories we are aware of which use the wrapper.
175
+
176
+
-[NMRium](https://www.nmrium.org/)
177
+
-[nmrXiv](https://nmrxiv.org/)
178
+
-[Chemotion](https://www.chemotion.net/)
179
+
=======
180
+
```docker run -it --rm -p 1337:80 nmrium-rw:prod```
181
+
182
+
### Wrapper Events
183
+
184
+
NMRium wrapper uses a custom event to handle the communication between NMRium and the parent application, for that we create multiple events:
185
+
186
+
#### Events in action
187
+
you can use the events helper functions or create message events manually.
188
+
189
+
1. Helper function
190
+
191
+
```ts
192
+
importeventsfrom'../events';
193
+
194
+
events.trigger(eventName, data);
195
+
196
+
events.on(eventName, listenerHandler);
197
+
198
+
```
199
+
200
+
2. Message event
201
+
202
+
```ts
203
+
window.postMessage({ type: `nmr-wrapper:${eventName}`, data }, '*');
0 commit comments