cedar-embeddable-editor 0.9.7 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -33
- package/cedar-embeddable-editor.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,9 @@ It takes CEDAR JSON Schema templates as input, and produces CEDAR JSON-LD metada
|
|
|
6
6
|
|
|
7
7
|
## Running as a standalone application
|
|
8
8
|
|
|
9
|
-
You can run CEE as a standalone application. This is helpful for developers to see changes to the code reflected immediately in the application. To run CEE in the standalone mode (NOT as a Webcomponent),
|
|
9
|
+
You can run CEE as a standalone application. This is helpful for developers to see changes to the code reflected immediately in the application. To run CEE in the standalone mode (NOT as a Webcomponent), you will need the editor itself and the sample templates that the editor uses. These are stored in a [separate repo](https://github.com/metadatacenter/cedar-component-distribution).
|
|
10
|
+
|
|
11
|
+
Proceed with the following steps:
|
|
10
12
|
|
|
11
13
|
### Clone the repository
|
|
12
14
|
|
|
@@ -14,6 +16,7 @@ Clone this repository onto a local directory of your choice:
|
|
|
14
16
|
|
|
15
17
|
```shell
|
|
16
18
|
git clone https://github.com/metadatacenter/cedar-embeddable-editor.git
|
|
19
|
+
git clone https://github.com/metadatacenter/cedar-component-distribution.git
|
|
17
20
|
```
|
|
18
21
|
|
|
19
22
|
### Edit configuration
|
|
@@ -25,30 +28,46 @@ git clone https://github.com/metadatacenter/cedar-embeddable-editor.git
|
|
|
25
28
|
|
|
26
29
|
1. Navigate to the CEE directory:
|
|
27
30
|
```shell
|
|
28
|
-
$cd <...>/<clone directory>/cedar-embeddable-editor/
|
|
31
|
+
$ cd <...>/<clone directory>/cedar-embeddable-editor/
|
|
32
|
+
```
|
|
33
|
+
1. Run these commands:
|
|
34
|
+
```shell
|
|
35
|
+
cedar-embeddable-editor$ npm install
|
|
36
|
+
cedar-embeddable-editor$ ng serve
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
1. In a different shell navigate to the component distribution directory:
|
|
40
|
+
```shell
|
|
41
|
+
$ cd <...>/<clone directory>/cedar-component-distribution/
|
|
29
42
|
```
|
|
43
|
+
|
|
30
44
|
1. Run these commands:
|
|
31
45
|
```shell
|
|
32
46
|
cedar-embeddable-editor$ npm install
|
|
33
47
|
cedar-embeddable-editor$ ng serve
|
|
34
48
|
```
|
|
35
|
-
|
|
49
|
+
|
|
50
|
+
1. In your browser, navigate to `http://localhost:4400/`. The app will automatically reload if you change any of the source files.
|
|
36
51
|
|
|
37
52
|
## Running as a Webcomponent
|
|
38
53
|
|
|
39
|
-
This method creates a single Javascript (JS) file that encapsulates all the functionality of CEE. The JS file can be embedded in any application or HTML page. To build a CEE Webcomponent, proceed with these steps:
|
|
54
|
+
This method creates a single Javascript (JS) file that encapsulates all the functionality of CEE. The JS file can be embedded in any application or HTML page. To build a CEE Webcomponent, proceed with these steps:
|
|
40
55
|
|
|
41
56
|
### Build and copy the Webcomponent JS file
|
|
42
57
|
|
|
43
58
|
1. Run the build command:
|
|
44
59
|
```shell
|
|
45
|
-
cedar-embeddable-editor$ ng build --configuration
|
|
60
|
+
cedar-embeddable-editor$ ng build --configuration=production
|
|
46
61
|
```
|
|
47
62
|
1. Combine the generated files into a single file and copy the final JS to the sample application:
|
|
48
63
|
```shell
|
|
49
|
-
cedar-embeddable-editor$ cat dist/cedar-embeddable-editor/{runtime,polyfills,main}.js >
|
|
64
|
+
cedar-embeddable-editor$ cat dist/cedar-embeddable-editor/{runtime,polyfills,main}.js > cedar-embeddable-editor.js
|
|
50
65
|
```
|
|
51
66
|
|
|
67
|
+
## Running as an `npm` package
|
|
68
|
+
|
|
69
|
+
Please import the latest version of the editor into your project from: [https://www.npmjs.com/package/cedar-embeddable-editor](https://www.npmjs.com/package/cedar-embeddable-editor)
|
|
70
|
+
|
|
52
71
|
## Configuration
|
|
53
72
|
|
|
54
73
|
### Configuration file
|
|
@@ -63,18 +82,27 @@ document.addEventListener('WebComponentsReady', function () {
|
|
|
63
82
|
cee.loadConfigFromURL('assets/data/cee-config.json');
|
|
64
83
|
});
|
|
65
84
|
```
|
|
66
|
-
*
|
|
85
|
+
* The configuration can also be passed into the editor as a json map. In Angular this looks as follows:
|
|
86
|
+
```html
|
|
87
|
+
<cedar-embeddable-editor
|
|
88
|
+
[config]="conf"
|
|
89
|
+
[templateObject]="template"
|
|
90
|
+
[instanceObject]="instance"
|
|
91
|
+
></cedar-embeddable-editor>
|
|
92
|
+
```
|
|
67
93
|
|
|
68
94
|
|
|
69
95
|
### Required configuration parameters
|
|
70
96
|
|
|
71
|
-
* **
|
|
72
|
-
*
|
|
97
|
+
* **showSampleTemplateLinks:** Wether the sample links are shown or not.
|
|
98
|
+
* For production this should be false, the template should be injected into the component by the embedding application
|
|
99
|
+
* **terminologyIntegratedSearchUrl:** The URL of the CEDAR integrated search endpoint that communicates with BioPortal.
|
|
100
|
+
* The value `https://terminology.metadatacenter.org/bioportal/integrated-search` should work for the majority of applications.
|
|
73
101
|
|
|
74
102
|
```json
|
|
75
103
|
{
|
|
76
|
-
"
|
|
77
|
-
"terminologyIntegratedSearchUrl":
|
|
104
|
+
"showSampleTemplateLinks": false,
|
|
105
|
+
"terminologyIntegratedSearchUrl": 'https://terminology.metadatacenter.org/bioportal/integrated-search',
|
|
78
106
|
}
|
|
79
107
|
```
|
|
80
108
|
|
|
@@ -84,22 +112,30 @@ There are other optional configuration parameters available for controlling vari
|
|
|
84
112
|
|
|
85
113
|
```json
|
|
86
114
|
{
|
|
87
|
-
"
|
|
88
|
-
"loadSampleTemplateName": "
|
|
89
|
-
"expandedSampleTemplateLinks":
|
|
115
|
+
"sampleTemplateLocationPrefix": "http://localhost:4240/cedar-embeddable-editor-sample-templates/",
|
|
116
|
+
"loadSampleTemplateName": "01",
|
|
117
|
+
"expandedSampleTemplateLinks": true,
|
|
118
|
+
|
|
90
119
|
"showTemplateRenderingRepresentation": true,
|
|
91
|
-
"expandedTemplateRenderingRepresentation": false,
|
|
92
120
|
"showInstanceDataCore": true,
|
|
93
|
-
"expandedInstanceDataCore":
|
|
121
|
+
"expandedInstanceDataCore": false,
|
|
122
|
+
"showMultiInstanceInfo": true,
|
|
123
|
+
"expandedMultiInstanceInfo": false,
|
|
124
|
+
|
|
125
|
+
"expandedTemplateRenderingRepresentation": false,
|
|
94
126
|
"showInstanceDataFull": false,
|
|
95
127
|
"expandedInstanceDataFull": false,
|
|
96
|
-
"showMultiInstanceInfo": false,
|
|
97
|
-
"expandedMultiInstanceInfo": false,
|
|
98
128
|
"showTemplateSourceData": true,
|
|
99
129
|
"expandedTemplateSourceData": false,
|
|
130
|
+
|
|
100
131
|
"showHeader": true,
|
|
101
132
|
"showFooter": true,
|
|
102
|
-
|
|
133
|
+
|
|
134
|
+
"defaultLanguage": "en",
|
|
135
|
+
"fallbackLanguage": "en",
|
|
136
|
+
|
|
137
|
+
"collapseStaticComponents": false,
|
|
138
|
+
"showStaticText": true
|
|
103
139
|
}
|
|
104
140
|
```
|
|
105
141
|
|
|
@@ -136,15 +172,23 @@ document.addEventListener('WebComponentsReady', function () {
|
|
|
136
172
|
});
|
|
137
173
|
```
|
|
138
174
|
|
|
139
|
-
###
|
|
175
|
+
### Template Injection
|
|
140
176
|
|
|
141
|
-
You can
|
|
177
|
+
You can inject your template into CEE:
|
|
142
178
|
|
|
143
179
|
```javascript
|
|
144
|
-
cee.
|
|
180
|
+
cee.templateObject = yourCustomTemplateJson;
|
|
145
181
|
```
|
|
146
182
|
|
|
147
|
-
|
|
183
|
+
### Metadata Injection
|
|
184
|
+
|
|
185
|
+
You can inject your metadata into CEE, provided it matches the template currently being edited:
|
|
186
|
+
|
|
187
|
+
```javascript
|
|
188
|
+
cee.instanceObject = yourCustomMetadataJson
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
In the example below, the metadata is fetched from a remote URL and injected into CEE:
|
|
148
192
|
|
|
149
193
|
```javascript
|
|
150
194
|
function restoreMetadataFromURL(metaUrl, cee, successHandler = null, errorHandler = null) {
|
|
@@ -153,7 +197,7 @@ function restoreMetadataFromURL(metaUrl, cee, successHandler = null, errorHandle
|
|
|
153
197
|
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
154
198
|
if (xhr.status === 200) {
|
|
155
199
|
const jsonMeta = JSON.parse(xhr.responseText);
|
|
156
|
-
cee.
|
|
200
|
+
cee.instanceObject = jsonMeta;
|
|
157
201
|
|
|
158
202
|
if (successHandler) {
|
|
159
203
|
successHandler(jsonMeta);
|
|
@@ -176,20 +220,15 @@ document.addEventListener('WebComponentsReady', function () {
|
|
|
176
220
|
});
|
|
177
221
|
```
|
|
178
222
|
|
|
179
|
-
To reiterate, the metadata being
|
|
223
|
+
To reiterate, the metadata being injected **MUST** match the template currently being edited and open in your browser window.
|
|
180
224
|
|
|
181
225
|
## Example Applications
|
|
182
226
|
|
|
183
|
-
There
|
|
184
|
-
|
|
185
|
-
### CEE Demo Generic
|
|
186
|
-
|
|
187
|
-
This demo uses a generic HTML page with the CEE Webcomponent embedded in it. It runs standalone, with no dependency on any web framework.
|
|
188
|
-
|
|
189
|
-
https://github.com/metadatacenter/cedar-cee-demo-generic
|
|
227
|
+
There is a sample applications you can use to demonstrate how to embed and use CEE.
|
|
228
|
+
Follow the links below to the demo application of your choice. The documentation for each demo application can be found in the README file of the corresponding application.
|
|
190
229
|
|
|
191
230
|
### CEE Demo Angular
|
|
192
231
|
|
|
193
232
|
This demo is written in Angular 2 and requires that framework to run properly.
|
|
194
233
|
|
|
195
|
-
https://github.com/metadatacenter/cedar-cee-demo-angular
|
|
234
|
+
https://github.com/metadatacenter/cedar-cee-demo/tree/main/cedar-cee-demo-angular-src
|