@teipublisher/pb-components 2.25.5 → 2.25.7

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.
Files changed (130) hide show
  1. package/.github/workflows/main.yml +3 -3
  2. package/.github/workflows/node.js.yml +3 -3
  3. package/.github/workflows/release.js.yml +3 -3
  4. package/CHANGELOG.md +15 -0
  5. package/Dockerfile +78 -70
  6. package/css/components.css +5 -5
  7. package/dist/demo/pb-drawer2.html +1 -1
  8. package/dist/demo/pb-facsimile.html +2 -2
  9. package/dist/demo/pb-leaflet-map.html +1 -1
  10. package/dist/demo/pb-repeat.html +1 -3
  11. package/dist/demo/pb-view3.html +1 -1
  12. package/dist/{paper-icon-button-0fb125c4.js → paper-icon-button-72125e67.js} +1 -1
  13. package/dist/pb-code-editor.js +25 -20
  14. package/dist/pb-component-docs.js +58 -54
  15. package/dist/pb-components-bundle.js +1827 -1520
  16. package/dist/pb-edit-app.js +167 -107
  17. package/dist/pb-elements.json +54 -54
  18. package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
  19. package/dist/pb-leaflet-map.js +23 -23
  20. package/dist/pb-mei.js +56 -41
  21. package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
  22. package/dist/pb-odd-editor.js +925 -758
  23. package/dist/pb-tify.js +2 -2
  24. package/dist/{vaadin-element-mixin-859a0132.js → vaadin-element-mixin-ad07ba25.js} +88 -61
  25. package/gh-pages.js +5 -3
  26. package/lib/openseadragon.min.js +6 -6
  27. package/package.json +3 -2
  28. package/pb-elements.json +54 -54
  29. package/src/assets/components.css +5 -5
  30. package/src/authority/airtable.js +20 -21
  31. package/src/authority/anton.js +129 -129
  32. package/src/authority/custom.js +23 -21
  33. package/src/authority/geonames.js +38 -32
  34. package/src/authority/gnd.js +47 -42
  35. package/src/authority/kbga.js +137 -134
  36. package/src/authority/metagrid.js +44 -46
  37. package/src/authority/reconciliation.js +66 -67
  38. package/src/authority/registry.js +4 -4
  39. package/src/docs/pb-component-docs.js +2 -2
  40. package/src/docs/pb-component-view.js +5 -5
  41. package/src/docs/pb-components-list.js +2 -2
  42. package/src/docs/pb-demo-snippet.js +2 -2
  43. package/src/dts-client.js +299 -297
  44. package/src/dts-select-endpoint.js +90 -82
  45. package/src/parse-date-service.js +184 -135
  46. package/src/pb-ajax.js +171 -167
  47. package/src/pb-authority-lookup.js +96 -81
  48. package/src/pb-autocomplete.js +292 -280
  49. package/src/pb-blacklab-highlight.js +264 -259
  50. package/src/pb-blacklab-results.js +236 -221
  51. package/src/pb-browse-docs.js +540 -475
  52. package/src/pb-browse.js +68 -65
  53. package/src/pb-clipboard.js +79 -76
  54. package/src/pb-code-editor.js +110 -102
  55. package/src/pb-code-highlight.js +209 -204
  56. package/src/pb-codepen.js +79 -72
  57. package/src/pb-collapse.js +149 -146
  58. package/src/pb-combo-box.js +190 -190
  59. package/src/pb-components-bundle.js +1 -1
  60. package/src/pb-custom-form.js +150 -149
  61. package/src/pb-document.js +89 -90
  62. package/src/pb-download.js +208 -195
  63. package/src/pb-drawer.js +145 -148
  64. package/src/pb-edit-app.js +301 -229
  65. package/src/pb-edit-xml.js +99 -96
  66. package/src/pb-events.js +114 -107
  67. package/src/pb-facs-link.js +104 -102
  68. package/src/pb-facsimile.js +444 -410
  69. package/src/pb-formula.js +151 -153
  70. package/src/pb-geolocation.js +129 -131
  71. package/src/pb-grid-action.js +53 -56
  72. package/src/pb-grid.js +231 -228
  73. package/src/pb-highlight.js +140 -140
  74. package/src/pb-hotkeys.js +40 -42
  75. package/src/pb-i18n.js +101 -104
  76. package/src/pb-image-strip.js +84 -78
  77. package/src/pb-lang.js +83 -70
  78. package/src/pb-leaflet-map.js +488 -485
  79. package/src/pb-link.js +126 -124
  80. package/src/pb-load.js +431 -426
  81. package/src/pb-login.js +275 -254
  82. package/src/pb-manage-odds.js +364 -318
  83. package/src/pb-map-icon.js +89 -89
  84. package/src/pb-map-layer.js +85 -85
  85. package/src/pb-markdown.js +90 -99
  86. package/src/pb-media-query.js +74 -72
  87. package/src/pb-mei.js +306 -295
  88. package/src/pb-message.js +143 -130
  89. package/src/pb-mixin.js +269 -264
  90. package/src/pb-navigation.js +80 -82
  91. package/src/pb-observable.js +38 -38
  92. package/src/pb-odd-editor.js +1056 -958
  93. package/src/pb-odd-elementspec-editor.js +348 -297
  94. package/src/pb-odd-model-editor.js +1058 -898
  95. package/src/pb-odd-parameter-editor.js +200 -178
  96. package/src/pb-odd-rendition-editor.js +136 -124
  97. package/src/pb-page.js +432 -422
  98. package/src/pb-paginate.js +202 -190
  99. package/src/pb-panel.js +191 -179
  100. package/src/pb-popover-themes.js +7 -5
  101. package/src/pb-popover.js +296 -287
  102. package/src/pb-print-preview.js +127 -127
  103. package/src/pb-progress.js +49 -49
  104. package/src/pb-repeat.js +105 -104
  105. package/src/pb-restricted.js +84 -77
  106. package/src/pb-search.js +238 -221
  107. package/src/pb-select-feature.js +127 -120
  108. package/src/pb-select-odd.js +132 -124
  109. package/src/pb-select-template.js +89 -78
  110. package/src/pb-select.js +251 -227
  111. package/src/pb-split-list.js +179 -174
  112. package/src/pb-svg.js +80 -79
  113. package/src/pb-table-column.js +54 -54
  114. package/src/pb-table-grid.js +221 -203
  115. package/src/pb-tabs.js +61 -63
  116. package/src/pb-tify.js +154 -154
  117. package/src/pb-timeline.js +271 -229
  118. package/src/pb-toggle-feature.js +198 -185
  119. package/src/pb-upload.js +184 -174
  120. package/src/pb-version.js +30 -30
  121. package/src/pb-view-annotate.js +132 -98
  122. package/src/pb-view.js +1282 -1263
  123. package/src/pb-zoom.js +40 -40
  124. package/src/polymer-hack.js +1 -1
  125. package/src/search-result-service.js +256 -223
  126. package/src/seed-element.js +13 -20
  127. package/src/settings.js +4 -4
  128. package/src/theming.js +91 -91
  129. package/src/urls.js +289 -289
  130. package/src/utils.js +53 -51
@@ -14,15 +14,14 @@ import '@polymer/paper-listbox/paper-listbox.js';
14
14
  import '@polymer/paper-item/paper-item.js';
15
15
  import '@polymer/paper-styles/color.js';
16
16
  import '@polymer/iron-collapse/iron-collapse.js';
17
- import "@jinntec/jinn-codemirror/dist/src/jinn-codemirror";
17
+ import '@jinntec/jinn-codemirror/dist/src/jinn-codemirror';
18
18
 
19
19
  import { cmpVersion } from './utils.js';
20
20
  import './pb-odd-rendition-editor.js';
21
21
  import './pb-odd-parameter-editor.js';
22
22
  import './pb-message.js';
23
23
 
24
- import { get as i18n, translate } from "./pb-i18n.js";
25
-
24
+ import { get as i18n, translate } from './pb-i18n.js';
26
25
 
27
26
  /**
28
27
  * represents an odd model element for editing
@@ -32,398 +31,401 @@ import { get as i18n, translate } from "./pb-i18n.js";
32
31
  * @polymer
33
32
  */
34
33
  export class PbOddModelEditor extends LitElement {
35
-
36
- static get styles() {
37
- return css`
38
- :host {
39
- display: flex;
40
- flex-direction:column;
41
- }
42
- h1, h2, h3, h4, h5, h6 {
43
- font-family: "Oswald", Verdana, "Helvetica", sans-serif;
44
- font-weight: 400 !important;
45
- }
46
-
47
- form {
48
- margin-bottom: 8px;
49
- }
50
-
51
- paper-input, paper-autocomplete {
52
- margin-bottom: 16px;
53
- }
54
-
55
- .models {
56
- margin-left:20px;
57
- margin-top:10px;
58
- }
59
-
60
- .btn, .btn-group {
61
- margin-top: 0;
62
- margin-bottom: 0;
63
- }
64
-
65
- header {
66
- // background-color: #d1dae0;
67
- background:var(--paper-grey-300);
68
- margin:0;
69
- }
70
-
71
- header div {
72
- display: flex;
73
- flex-direction: row;
74
- justify-content: space-between;
75
- align-items: center;
76
- }
77
-
78
- header h4 {
79
- padding: 4px 8px;
80
- margin: 0;
81
- display: grid;
82
- grid-template-columns: 40px 40% auto;
83
- }
84
- h4 .btn-group{
85
- text-align: right;
86
- display: none;
87
- }
88
-
89
- #toggle, .modelType{
90
- align-self:center;
91
- }
92
-
93
- header div.info {
94
- padding: 0 16px 4px;
95
- margin: 0;
96
- font-size: 85%;
97
- display: block;
98
- margin:0 0 0 32px;
99
- }
100
- header div.info *{
101
- display: block;
102
- line-height: 1.2;
103
- }
104
-
105
- header .outputDisplay{
106
- text-transform: uppercase ;
107
- }
108
- header .description{
109
- font-style: italic;
110
- }
111
-
112
- header .predicate {
113
- color: #ff5722;
114
- }
115
-
116
- .predicate label, .template label {
117
- display: block;
118
- font-size: 12px;
119
- font-weight: 300;
120
- color: rgb(115, 115, 115);
121
- }
122
-
123
- .model-collapse {
124
- color: #000000;
125
- cursor: pointer;
126
- }
127
-
128
- .model-collapse:hover {
129
- text-decoration: none;
130
- }
131
-
132
- .behaviour {
133
- color: #ff5722;
134
- }
135
-
136
- .behaviour:before {
137
- content: ' [';
138
- }
139
-
140
- .behaviour:after {
141
- content: ']';
142
- }
143
-
144
- .behaviourWrapper{
145
- display:grid;
146
- grid-template-columns: 140px 40px 140px auto;
147
- }
148
- .behaviourWrapper > *{
149
- display:inline;
150
- align-self:stretch;
151
- }
152
-
153
- .group {
154
- margin: 0;
155
- font-size: 16px;
156
- font-weight: bold;
157
- }
158
-
159
- .group .title {
160
- /*text-decoration: underline;*/
161
- }
162
-
163
- .renditions, .parameters {
164
- padding-left: 16px;
165
- border-left: 3px solid #e0e0e0;
166
- margin-bottom:20px;
167
- }
168
-
169
- .renditions .group {
170
- display: flex;
171
- flex-direction: row;
172
- justify-content: space-between;
173
- align-items: center;
174
- }
175
-
176
- .predicate .form-control {
177
- width: 100%;
178
- }
179
-
180
- .source {
181
- text-decoration: none;
182
- margin-bottom: 8px;
183
- }
184
-
185
- .selectOutput {
186
- margin-right: 10px;
187
- }
188
-
189
- :host([currentselection]) > form > header{
190
- @apply --shadow-elevation-4dp;
191
- border-left:3px solid var(--paper-blue-500);
192
- }
193
-
194
- paper-menu-button paper-icon-button{
195
- margin-left:-10px;
196
- }
197
-
198
- /* need to play it save for FF */
199
- :host([currentselection]) > form > header > h4 > .btn-group{
200
- display: inline-block;
201
- }
202
- iron-collapse{
203
- }
204
-
205
- .renditions{
206
- margin-top:10px;
207
- }
208
-
209
- .details{
210
- padding:0px 50px 20px 20px;
211
- background:var(--paper-grey-200);
212
- }
213
-
214
- .editor {
215
- margin-bottom: 20px;
216
- }
217
-
218
- .editor label {
219
- margin-bottom:5px;
220
- font-size: 12px;
221
- font-weight: 400;
222
- color: var(--paper-grey-500);
223
- }
224
-
225
- .horizontal {
226
- display: flex;
227
- flex-wrap: wrap;
228
- justify-content: space-between;
229
- }
230
-
231
- #mode {
232
- min-width: 18em;
233
- }
234
- `;
235
- }
236
-
237
- static get properties() {
238
- return {
239
- /**
240
- * maps to ODD ´model` behaviour attribute
241
- */
242
- behaviour: {
243
- type: String
244
- },
245
- /**
246
- * maps to ODD `model` predicate
247
- */
248
- predicate: {
249
- type: String,
250
- reflect: true,
251
- converter: (value, type) => {
252
- if (value.toLowerCase() === 'null') {
253
- return '';
254
- }
255
- return value;
256
- }
257
- },
258
- type: {
259
- type: String,
260
- reflect: true
261
- },
262
- template: {
263
- type: String,
264
- reflect: true,
265
- converter: (value, type) => {
266
- if (value.toLowerCase() === 'null') {
267
- return '';
268
- }
269
- return value;
270
- }
271
- },
272
- output: {
273
- type: String,
274
- reflect: true,
275
- converter: (value, type) => {
276
- if (value.toLowerCase() === 'null') {
277
- return '';
278
- }
279
- return value;
280
- }
281
- },
282
- css: {
283
- type: String,
284
- converter: (value, type) => {
285
- if (value.toLowerCase() === 'null') {
286
- return '';
287
- }
288
- return value;
289
- }
290
- },
291
- mode: {
292
- type: String
293
- },
294
- model: {
295
- type: Object
296
- },
297
- models: {
298
- type: Array
299
- },
300
- parameters: {
301
- type: Array
302
- },
303
- renditions: {
304
- type: Array
305
- },
306
- desc: {
307
- type: String,
308
- converter: (value, type) => {
309
- if (value.toLowerCase() === 'null') {
310
- return '';
311
- }
312
- return value;
313
- }
314
- },
315
- sourcerend: {
316
- type: String
317
- },
318
- show: {
319
- type: Boolean,
320
- reflect: true
321
- },
322
- outputs: {
323
- type: Array
324
- },
325
- behaviours: {
326
- type: Array
327
- },
328
- icon: {
329
- type: String
330
- },
331
- open: {
332
- type: String
333
- },
334
- hasCustomBehaviour: {
335
- type: Boolean
336
- },
337
- endpoint: {
338
- type: String
339
- },
340
- apiVersion: {
341
- type: String
342
- }
343
- };
344
- }
345
-
346
- constructor() {
347
- super();
348
- this.behaviour = 'inline';
349
- this.predicate = '';
350
- this.type = '';
351
- this.template = '';
352
- this.output = '';
353
- this.css = '';
354
- this.mode = '';
355
- this.model = {};
356
- this.model.models = [];
357
- this.parameters = [];
358
- this.renditions = [];
359
- this.desc = '';
360
- this.sourcerend = '';
361
- this.show = false;
362
-
363
- this.outputs = ["",
364
- "web",
365
- "print",
366
- "epub",
367
- "fo",
368
- "latex",
369
- "plain"];
370
-
371
- this.parentModel = [];
372
- this.behaviours = [
373
- "alternate",
374
- "anchor",
375
- "block",
376
- "body",
377
- "break",
378
- "cell",
379
- "cit",
380
- "document",
381
- "figure",
382
- "graphic",
383
- "heading",
384
- "inline",
385
- "link",
386
- "list",
387
- "listItem",
388
- "metadata",
389
- "note",
390
- "omit",
391
- "paragraph",
392
- "pass-through",
393
- "row",
394
- "section",
395
- "table",
396
- "text",
397
- "title",
398
- "webcomponent"
399
- ];
400
-
401
- this.icon = 'expand-more';
402
- this.hasCustomBehaviour = false;
34
+ static get styles() {
35
+ return css`
36
+ :host {
37
+ display: flex;
38
+ flex-direction: column;
39
+ }
40
+ h1,
41
+ h2,
42
+ h3,
43
+ h4,
44
+ h5,
45
+ h6 {
46
+ font-family: 'Oswald', Verdana, 'Helvetica', sans-serif;
47
+ font-weight: 400 !important;
48
+ }
49
+
50
+ form {
51
+ margin-bottom: 8px;
52
+ }
53
+
54
+ paper-input,
55
+ paper-autocomplete {
56
+ margin-bottom: 16px;
57
+ }
58
+
59
+ .models {
60
+ margin-left: 20px;
61
+ margin-top: 10px;
62
+ }
63
+
64
+ .btn,
65
+ .btn-group {
66
+ margin-top: 0;
67
+ margin-bottom: 0;
68
+ }
69
+
70
+ header {
71
+ // background-color: #d1dae0;
72
+ background: var(--paper-grey-300);
73
+ margin: 0;
74
+ }
75
+
76
+ header div {
77
+ display: flex;
78
+ flex-direction: row;
79
+ justify-content: space-between;
80
+ align-items: center;
81
+ }
82
+
83
+ header h4 {
84
+ padding: 4px 8px;
85
+ margin: 0;
86
+ display: grid;
87
+ grid-template-columns: 40px 40% auto;
88
+ }
89
+ h4 .btn-group {
90
+ text-align: right;
91
+ display: none;
92
+ }
93
+
94
+ #toggle,
95
+ .modelType {
96
+ align-self: center;
97
+ }
98
+
99
+ header div.info {
100
+ padding: 0 16px 4px;
101
+ margin: 0;
102
+ font-size: 85%;
103
+ display: block;
104
+ margin: 0 0 0 32px;
105
+ }
106
+ header div.info * {
107
+ display: block;
108
+ line-height: 1.2;
109
+ }
110
+
111
+ header .outputDisplay {
112
+ text-transform: uppercase;
113
+ }
114
+ header .description {
115
+ font-style: italic;
116
+ }
117
+
118
+ header .predicate {
119
+ color: #ff5722;
120
+ }
121
+
122
+ .predicate label,
123
+ .template label {
124
+ display: block;
125
+ font-size: 12px;
126
+ font-weight: 300;
127
+ color: rgb(115, 115, 115);
128
+ }
129
+
130
+ .model-collapse {
131
+ color: #000000;
132
+ cursor: pointer;
133
+ }
134
+
135
+ .model-collapse:hover {
136
+ text-decoration: none;
137
+ }
138
+
139
+ .behaviour {
140
+ color: #ff5722;
141
+ }
142
+
143
+ .behaviour:before {
144
+ content: ' [';
145
+ }
146
+
147
+ .behaviour:after {
148
+ content: ']';
149
+ }
150
+
151
+ .behaviourWrapper {
152
+ display: grid;
153
+ grid-template-columns: 140px 40px 140px auto;
154
+ }
155
+ .behaviourWrapper > * {
156
+ display: inline;
157
+ align-self: stretch;
158
+ }
159
+
160
+ .group {
161
+ margin: 0;
162
+ font-size: 16px;
163
+ font-weight: bold;
164
+ }
165
+
166
+ .group .title {
167
+ /*text-decoration: underline;*/
168
+ }
169
+
170
+ .renditions,
171
+ .parameters {
172
+ padding-left: 16px;
173
+ border-left: 3px solid #e0e0e0;
174
+ margin-bottom: 20px;
175
+ }
176
+
177
+ .renditions .group {
178
+ display: flex;
179
+ flex-direction: row;
180
+ justify-content: space-between;
181
+ align-items: center;
182
+ }
183
+
184
+ .predicate .form-control {
185
+ width: 100%;
186
+ }
187
+
188
+ .source {
189
+ text-decoration: none;
190
+ margin-bottom: 8px;
191
+ }
192
+
193
+ .selectOutput {
194
+ margin-right: 10px;
195
+ }
196
+
197
+ :host([currentselection]) > form > header {
198
+ @apply --shadow-elevation-4dp;
199
+ border-left: 3px solid var(--paper-blue-500);
200
+ }
201
+
202
+ paper-menu-button paper-icon-button {
203
+ margin-left: -10px;
204
+ }
205
+
206
+ /* need to play it save for FF */
207
+ :host([currentselection]) > form > header > h4 > .btn-group {
208
+ display: inline-block;
209
+ }
210
+ iron-collapse {
211
+ }
212
+
213
+ .renditions {
214
+ margin-top: 10px;
215
+ }
216
+
217
+ .details {
218
+ padding: 0px 50px 20px 20px;
219
+ background: var(--paper-grey-200);
220
+ }
221
+
222
+ .editor {
223
+ margin-bottom: 20px;
224
+ }
225
+
226
+ .editor label {
227
+ margin-bottom: 5px;
228
+ font-size: 12px;
229
+ font-weight: 400;
230
+ color: var(--paper-grey-500);
231
+ }
232
+
233
+ .horizontal {
234
+ display: flex;
235
+ flex-wrap: wrap;
236
+ justify-content: space-between;
237
+ }
238
+
239
+ #mode {
240
+ min-width: 18em;
241
+ }
242
+ `;
243
+ }
244
+
245
+ static get properties() {
246
+ return {
247
+ /**
248
+ * maps to ODD ´model` behaviour attribute
249
+ */
250
+ behaviour: {
251
+ type: String,
252
+ },
253
+ /**
254
+ * maps to ODD `model` predicate
255
+ */
256
+ predicate: {
257
+ type: String,
258
+ reflect: true,
259
+ converter: (value, type) => {
260
+ if (value.toLowerCase() === 'null') {
261
+ return '';
262
+ }
263
+ return value;
264
+ },
265
+ },
266
+ type: {
267
+ type: String,
268
+ reflect: true,
269
+ },
270
+ template: {
271
+ type: String,
272
+ reflect: true,
273
+ converter: (value, type) => {
274
+ if (value.toLowerCase() === 'null') {
275
+ return '';
276
+ }
277
+ return value;
278
+ },
279
+ },
280
+ output: {
281
+ type: String,
282
+ reflect: true,
283
+ converter: (value, type) => {
284
+ if (value.toLowerCase() === 'null') {
285
+ return '';
286
+ }
287
+ return value;
288
+ },
289
+ },
290
+ css: {
291
+ type: String,
292
+ converter: (value, type) => {
293
+ if (value.toLowerCase() === 'null') {
294
+ return '';
295
+ }
296
+ return value;
297
+ },
298
+ },
299
+ mode: {
300
+ type: String,
301
+ },
302
+ model: {
303
+ type: Object,
304
+ },
305
+ models: {
306
+ type: Array,
307
+ },
308
+ parameters: {
309
+ type: Array,
310
+ },
311
+ renditions: {
312
+ type: Array,
313
+ },
314
+ desc: {
315
+ type: String,
316
+ converter: (value, type) => {
317
+ if (value.toLowerCase() === 'null') {
318
+ return '';
319
+ }
320
+ return value;
321
+ },
322
+ },
323
+ sourcerend: {
324
+ type: String,
325
+ },
326
+ show: {
327
+ type: Boolean,
328
+ reflect: true,
329
+ },
330
+ outputs: {
331
+ type: Array,
332
+ },
333
+ behaviours: {
334
+ type: Array,
335
+ },
336
+ icon: {
337
+ type: String,
338
+ },
339
+ open: {
340
+ type: String,
341
+ },
342
+ hasCustomBehaviour: {
343
+ type: Boolean,
344
+ },
345
+ endpoint: {
346
+ type: String,
347
+ },
348
+ apiVersion: {
349
+ type: String,
350
+ },
351
+ };
352
+ }
353
+
354
+ constructor() {
355
+ super();
356
+ this.behaviour = 'inline';
357
+ this.predicate = '';
358
+ this.type = '';
359
+ this.template = '';
360
+ this.output = '';
361
+ this.css = '';
362
+ this.mode = '';
363
+ this.model = {};
364
+ this.model.models = [];
365
+ this.parameters = [];
366
+ this.renditions = [];
367
+ this.desc = '';
368
+ this.sourcerend = '';
369
+ this.show = false;
370
+
371
+ this.outputs = ['', 'web', 'print', 'epub', 'fo', 'latex', 'plain'];
372
+
373
+ this.parentModel = [];
374
+ this.behaviours = [
375
+ 'alternate',
376
+ 'anchor',
377
+ 'block',
378
+ 'body',
379
+ 'break',
380
+ 'cell',
381
+ 'cit',
382
+ 'document',
383
+ 'figure',
384
+ 'graphic',
385
+ 'heading',
386
+ 'inline',
387
+ 'link',
388
+ 'list',
389
+ 'listItem',
390
+ 'metadata',
391
+ 'note',
392
+ 'omit',
393
+ 'paragraph',
394
+ 'pass-through',
395
+ 'row',
396
+ 'section',
397
+ 'table',
398
+ 'text',
399
+ 'title',
400
+ 'webcomponent',
401
+ ];
402
+
403
+ this.icon = 'expand-more';
404
+ this.hasCustomBehaviour = false;
405
+ }
406
+
407
+ render() {
408
+ let tmplSyntax;
409
+ switch (this.output) {
410
+ case 'web':
411
+ case 'epub':
412
+ tmplSyntax = 'html';
413
+ break;
414
+ case 'latex':
415
+ tmplSyntax = 'tex';
416
+ break;
417
+ case 'plain':
418
+ tmplSyntax = 'default';
419
+ break;
420
+ case 'fo':
421
+ case 'print':
422
+ tmplSyntax = 'xml';
423
+ break;
424
+ default:
425
+ tmplSyntax = 'html';
426
+ break;
403
427
  }
404
-
405
- render() {
406
- let tmplSyntax;
407
- switch (this.output) {
408
- case 'web':
409
- case 'epub':
410
- tmplSyntax = 'html';
411
- break;
412
- case 'latex':
413
- tmplSyntax = 'tex';
414
- break;
415
- case 'plain':
416
- tmplSyntax = 'default';
417
- break;
418
- case 'fo':
419
- case 'print':
420
- tmplSyntax = 'xml';
421
- break;
422
- default:
423
- tmplSyntax = 'html';
424
- break;
425
- }
426
- return html`
428
+ return html`
427
429
  <form>
428
430
  <header>
429
431
  <h4>
@@ -431,37 +433,57 @@ export class PbOddModelEditor extends LitElement {
431
433
  icon="${this.icon}" @click="${this.toggle}"
432
434
  class="model-collapse"></paper-icon-button>
433
435
 
434
- <span class="modelType">${this.type}<span class="behaviour" ?hidden="${this._isGroupOrSequence()}">${this.behaviour}</span></span>
436
+ <span class="modelType">${
437
+ this.type
438
+ }<span class="behaviour" ?hidden="${this._isGroupOrSequence()}">${
439
+ this.behaviour
440
+ }</span></span>
435
441
 
436
442
  <span class="btn-group">
437
443
  <paper-icon-button @click="${this._moveDown}" icon="arrow-downward"
438
444
  title="move down"></paper-icon-button>
439
445
  <paper-icon-button @click="${this._moveUp}" icon="arrow-upward"
440
446
  title="move up"></paper-icon-button>
441
- <paper-icon-button @click="${this._requestRemoval}" icon="delete" title="remove"></paper-icon-button>
442
- <paper-icon-button @click="${this._copy}" icon="content-copy" title="copy"></paper-icon-button>
443
- <paper-icon-button @click="${this._paste}" icon="content-paste"></paper-icon-button>
444
-
445
- ${this._isGroupOrSequence() ?
446
- html`
447
- <paper-menu-button horizontal-align="right">
448
- <paper-icon-button icon="add" slot="dropdown-trigger"></paper-icon-button>
449
- <paper-listbox id="modelType" slot="dropdown-content" @iron-select="${this._addNested}"
450
- attr-for-selected="value">
451
- ${this.type === 'modelSequence' ?
452
- html`
453
- <paper-item value="model">model</paper-item>
454
- `: ''
455
- }
456
- ${this.type === 'modelGrp' ?
457
- html`
458
- <paper-item value="modelSequence">modelSequence</paper-item>
459
- <paper-item value="model">model</paper-item>
460
- `: ''
461
- }
462
- </paper-listbox>
463
- </paper-menu-button>
464
- `: ''}
447
+ <paper-icon-button @click="${
448
+ this._requestRemoval
449
+ }" icon="delete" title="remove"></paper-icon-button>
450
+ <paper-icon-button @click="${
451
+ this._copy
452
+ }" icon="content-copy" title="copy"></paper-icon-button>
453
+ <paper-icon-button @click="${
454
+ this._paste
455
+ }" icon="content-paste"></paper-icon-button>
456
+
457
+ ${
458
+ this._isGroupOrSequence()
459
+ ? html`
460
+ <paper-menu-button horizontal-align="right">
461
+ <paper-icon-button
462
+ icon="add"
463
+ slot="dropdown-trigger"
464
+ ></paper-icon-button>
465
+ <paper-listbox
466
+ id="modelType"
467
+ slot="dropdown-content"
468
+ @iron-select="${this._addNested}"
469
+ attr-for-selected="value"
470
+ >
471
+ ${this.type === 'modelSequence'
472
+ ? html` <paper-item value="model">model</paper-item> `
473
+ : ''}
474
+ ${this.type === 'modelGrp'
475
+ ? html`
476
+ <paper-item value="modelSequence"
477
+ >modelSequence</paper-item
478
+ >
479
+ <paper-item value="model">model</paper-item>
480
+ `
481
+ : ''}
482
+ </paper-listbox>
483
+ </paper-menu-button>
484
+ `
485
+ : ''
486
+ }
465
487
  </span>
466
488
  </h4>
467
489
  <div class="info">
@@ -476,10 +498,9 @@ export class PbOddModelEditor extends LitElement {
476
498
  <paper-listbox id="output" slot="dropdown-content" attr-for-selected="value"
477
499
  selected="${this.output}" @iron-select="${this._selectOutput}">
478
500
 
479
- ${this.outputs.map((item) =>
480
- html`
481
- <paper-item value="${item}">${item}</paper-item>
482
- `)}
501
+ ${this.outputs.map(
502
+ item => html` <paper-item value="${item}">${item}</paper-item> `,
503
+ )}
483
504
 
484
505
  </paper-listbox>
485
506
  </paper-dropdown-menu>
@@ -488,7 +509,9 @@ export class PbOddModelEditor extends LitElement {
488
509
  label="Mode"
489
510
  @change="${this._inputMode}"></paper-input>
490
511
  </div>
491
- <paper-input id="desc" .value="${this.desc}" placeholder="${translate('odd.editor.model.description-placeholder')}"
512
+ <paper-input id="desc" .value="${this.desc}" placeholder="${translate(
513
+ 'odd.editor.model.description-placeholder',
514
+ )}"
492
515
  label="Description" @change="${this._inputDesc}"></paper-input>
493
516
 
494
517
  <div class="editor">
@@ -496,522 +519,659 @@ export class PbOddModelEditor extends LitElement {
496
519
  <jinn-codemirror id="predicate"
497
520
  code="${this.predicate}"
498
521
  mode="xquery"
499
- linter="${this.endpoint}/${cmpVersion(this.apiVersion, '1.0.0') < 0 ? 'modules/editor.xql' : 'api/lint'}"
522
+ linter="${this.endpoint}/${
523
+ cmpVersion(this.apiVersion, '1.0.0') < 0 ? 'modules/editor.xql' : 'api/lint'
524
+ }"
500
525
  placeholder="${translate('odd.editor.model.predicate-placeholder')}"
501
526
  @update="${this._updatePredicate}"></jinn-codemirror>
502
527
  </div>
503
528
 
504
- ${this._isModel()
505
- ? html`
529
+ ${
530
+ this._isModel()
531
+ ? html`
506
532
  <div>
507
- <div class="behaviourWrapper">
508
- <paper-dropdown-menu label="behaviour" id="behaviourMenu" ?disabled="${this.hasCustomBehaviour}">
509
- <paper-listbox id="behaviour" slot="dropdown-content" attr-for-selected="value"
510
- selected="${this.behaviour}" @iron-select="${this._selectBehaviour}">
511
- ${this.behaviours.map((item) =>
512
- html`
513
- <paper-item value="${item}">${item}</paper-item>
514
- `)}
515
- </paper-listbox>
516
- </paper-dropdown-menu>
517
- <span style="align-self:center;justify-self: center;"> ${translate('odd.editor.model.link-with-or')} </span>
518
- <paper-input id="custombehaviour" label="" @input="${this._handleCustomBehaviour}" placeHolder="${translate('odd.editor.model.custom-behaviour-placeholder')}"></paper-input>
519
- <span></span>
520
- </div>
521
-
522
-
523
-
524
- <paper-input id="css" .value="${this.css}"
525
- placeholder="${translate('odd.editor.model.css-class-placeholder')}"
526
- label="CSS Class"
527
- @change="${this._inputCss}"></paper-input>
528
-
529
- <div class="editor">
530
- <label>Template</label>
531
- <jinn-codemirror id="template"
532
- code="${this.template}"
533
- mode="${tmplSyntax}"
534
- placeholder="${translate('odd.editor.model.template-placeholder')}"
535
- @update="${this._updateTemplate}">
536
- <div slot="toolbar">
537
- <paper-button data-mode="xml" data-command="selectElement" data-key="mod-e mod-s"
538
- title="Select element around current cursor position">&lt;|></paper-button>
539
- <paper-button data-mode="xml" data-command="encloseWith" data-key="mod-e mod-e"
540
- title="Enclose selection in new element">&lt;...&gt;</paper-button>
541
- <paper-button data-mode="xml" data-command="removeEnclosing" title="Remove enclosing tags"
542
- data-key="mod-e mod-r" class="sep">&lt;X></paper-button>
543
- <paper-button data-mode="html" data-command="selectElement" data-key="mod-e mod-s"
544
- title="Select element around current cursor position">&lt;|></paper-button>
545
- <paper-button data-mode="html" data-command="encloseWith" data-key="mod-e mod-e"
546
- title="Enclose selection in new element">&lt;...&gt;</paper-button>
547
- <paper-button data-mode="html" data-command="removeEnclosing" title="Remove enclosing tags"
548
- data-key="mod-e mod-r" class="sep">&lt;X></paper-button>
549
- <paper-button data-key="mod-e mod-p" data-command="snippet" data-params="[[\${_}]]" title="Insert template variable">[[...]]</paper-button>
550
- </div>
551
- </jinn-codemirror>
552
- </div>
533
+ <div class="behaviourWrapper">
534
+ <paper-dropdown-menu
535
+ label="behaviour"
536
+ id="behaviourMenu"
537
+ ?disabled="${this.hasCustomBehaviour}"
538
+ >
539
+ <paper-listbox
540
+ id="behaviour"
541
+ slot="dropdown-content"
542
+ attr-for-selected="value"
543
+ selected="${this.behaviour}"
544
+ @iron-select="${this._selectBehaviour}"
545
+ >
546
+ ${this.behaviours.map(
547
+ item => html` <paper-item value="${item}">${item}</paper-item> `,
548
+ )}
549
+ </paper-listbox>
550
+ </paper-dropdown-menu>
551
+ <span style="align-self:center;justify-self: center;">
552
+ ${translate('odd.editor.model.link-with-or')}
553
+ </span>
554
+ <paper-input
555
+ id="custombehaviour"
556
+ label=""
557
+ @input="${this._handleCustomBehaviour}"
558
+ placeHolder="${translate(
559
+ 'odd.editor.model.custom-behaviour-placeholder',
560
+ )}"
561
+ ></paper-input>
562
+ <span></span>
563
+ </div>
564
+
565
+ <paper-input
566
+ id="css"
567
+ .value="${this.css}"
568
+ placeholder="${translate('odd.editor.model.css-class-placeholder')}"
569
+ label="CSS Class"
570
+ @change="${this._inputCss}"
571
+ ></paper-input>
572
+
573
+ <div class="editor">
574
+ <label>Template</label>
575
+ <jinn-codemirror
576
+ id="template"
577
+ code="${this.template}"
578
+ mode="${tmplSyntax}"
579
+ placeholder="${translate('odd.editor.model.template-placeholder')}"
580
+ @update="${this._updateTemplate}"
581
+ >
582
+ <div slot="toolbar">
583
+ <paper-button
584
+ data-mode="xml"
585
+ data-command="selectElement"
586
+ data-key="mod-e mod-s"
587
+ title="Select element around current cursor position"
588
+ >&lt;|></paper-button
589
+ >
590
+ <paper-button
591
+ data-mode="xml"
592
+ data-command="encloseWith"
593
+ data-key="mod-e mod-e"
594
+ title="Enclose selection in new element"
595
+ >&lt;...&gt;</paper-button
596
+ >
597
+ <paper-button
598
+ data-mode="xml"
599
+ data-command="removeEnclosing"
600
+ title="Remove enclosing tags"
601
+ data-key="mod-e mod-r"
602
+ class="sep"
603
+ >&lt;X></paper-button
604
+ >
605
+ <paper-button
606
+ data-mode="html"
607
+ data-command="selectElement"
608
+ data-key="mod-e mod-s"
609
+ title="Select element around current cursor position"
610
+ >&lt;|></paper-button
611
+ >
612
+ <paper-button
613
+ data-mode="html"
614
+ data-command="encloseWith"
615
+ data-key="mod-e mod-e"
616
+ title="Enclose selection in new element"
617
+ >&lt;...&gt;</paper-button
618
+ >
619
+ <paper-button
620
+ data-mode="html"
621
+ data-command="removeEnclosing"
622
+ title="Remove enclosing tags"
623
+ data-key="mod-e mod-r"
624
+ class="sep"
625
+ >&lt;X></paper-button
626
+ >
627
+ <paper-button
628
+ data-key="mod-e mod-p"
629
+ data-command="snippet"
630
+ data-params="[[\${_}]]"
631
+ title="Insert template variable"
632
+ >[[...]]</paper-button
633
+ >
634
+ </div>
635
+ </jinn-codemirror>
636
+ </div>
553
637
  </div>
554
-
638
+
555
639
  <div class="parameters">
556
- <div class="group">
557
- <span class="title">Parameters</span>
558
- <paper-icon-button icon="add"
559
- @click="${this._addParameter}"></paper-icon-button>
560
- </div>
561
- ${repeat(this.parameters, (parameter) => parameter.name, (parameter, index) =>
562
- html`
563
- <pb-odd-parameter-editor
564
- behaviour="${this.behaviour}"
565
- name="${parameter.name}"
566
- value="${parameter.value}"
567
- ?set="${parameter.set}"
568
- endpoint="${this.endpoint}"
569
- apiVersion="${this.apiVersion}"
570
- @parameter-remove="${(e) => this._removeParam(e, index)}"
571
- @parameter-changed="${(e) => this._updateParam(e, index)}"
572
- ></pb-odd-parameter-editor>
573
- `)}
640
+ <div class="group">
641
+ <span class="title">Parameters</span>
642
+ <paper-icon-button
643
+ icon="add"
644
+ @click="${this._addParameter}"
645
+ ></paper-icon-button>
646
+ </div>
647
+ ${repeat(
648
+ this.parameters,
649
+ parameter => parameter.name,
650
+ (parameter, index) =>
651
+ html`
652
+ <pb-odd-parameter-editor
653
+ behaviour="${this.behaviour}"
654
+ name="${parameter.name}"
655
+ value="${parameter.value}"
656
+ ?set="${parameter.set}"
657
+ endpoint="${this.endpoint}"
658
+ apiVersion="${this.apiVersion}"
659
+ @parameter-remove="${e => this._removeParam(e, index)}"
660
+ @parameter-changed="${e => this._updateParam(e, index)}"
661
+ ></pb-odd-parameter-editor>
662
+ `,
663
+ )}
574
664
  </div>
575
665
 
576
666
  <div class="renditions">
577
- <div class="group">
578
- <div>
579
- <span class="title">Renditions</span>
580
- <paper-icon-button icon="add" @click="${this._addRendition}"></paper-icon-button>
581
- </div>
582
- <div class="source">
583
- <paper-checkbox ?checked="${this.sourcerend}" id="sourcerend">Use source rendition</paper-checkbox>
584
- </div>
667
+ <div class="group">
668
+ <div>
669
+ <span class="title">Renditions</span>
670
+ <paper-icon-button
671
+ icon="add"
672
+ @click="${this._addRendition}"
673
+ ></paper-icon-button>
585
674
  </div>
586
-
587
- ${repeat(this.renditions, (rendition) => rendition.name, (rendition, index) =>
588
- html`
589
- <pb-odd-rendition-editor scope="${rendition.scope}"
590
- css="${rendition.css}"
591
- @remove-rendition="${(e) => this._removeRendition(e, index)}"
592
- @rendition-changed="${(e) => this._updateRendition(e, index)}"
593
- ></pb-odd-rendition-editor>
594
- `)}
595
-
675
+ <div class="source">
676
+ <paper-checkbox ?checked="${this.sourcerend}" id="sourcerend"
677
+ >Use source rendition</paper-checkbox
678
+ >
679
+ </div>
680
+ </div>
681
+
682
+ ${repeat(
683
+ this.renditions,
684
+ rendition => rendition.name,
685
+ (rendition, index) =>
686
+ html`
687
+ <pb-odd-rendition-editor
688
+ scope="${rendition.scope}"
689
+ css="${rendition.css}"
690
+ @remove-rendition="${e => this._removeRendition(e, index)}"
691
+ @rendition-changed="${e => this._updateRendition(e, index)}"
692
+ ></pb-odd-rendition-editor>
693
+ `,
694
+ )}
596
695
  </div>
597
- `
598
- : ''
599
- }
696
+ `
697
+ : ''
698
+ }
600
699
  </iron-collapse>
601
700
 
602
701
  <div class="models">
603
- ${repeat(this.model.models, (model, index) => html`
604
- <pb-odd-model-editor
605
- behaviour="${model.behaviour || 'inline'}"
606
- predicate="${model.predicate}"
607
- type="${model.type}"
608
- output="${model.output}"
609
- css="${model.css}"
610
- mode="${model.mode}"
611
- .model="${model}"
612
- .parameters="${model.parameters}"
613
- desc="${model.desc}"
614
- sourcerend="${model.sourcerend}"
615
- .renditions="${model.renditions}"
616
- .template="${model.template}"
617
- .show="${model.show}"
618
- endpoint="${this.endpoint}"
619
- apiVersion="${this.apiVersion}"
620
- @model-remove="${this._removeModel}"
621
- @model-move-down="${this._moveModelDown}"
622
- @model-move-up="${this._moveModelUp}"
623
- @model-changed="${this.handleModelChanged}"
624
- @click="${ (e) => this.setCurrentSelection(e, index)}"
625
- hasParent
702
+ ${repeat(
703
+ this.model.models,
704
+ (model, index) => html`
705
+ <pb-odd-model-editor
706
+ behaviour="${model.behaviour || 'inline'}"
707
+ predicate="${model.predicate}"
708
+ type="${model.type}"
709
+ output="${model.output}"
710
+ css="${model.css}"
711
+ mode="${model.mode}"
712
+ .model="${model}"
713
+ .parameters="${model.parameters}"
714
+ desc="${model.desc}"
715
+ sourcerend="${model.sourcerend}"
716
+ .renditions="${model.renditions}"
717
+ .template="${model.template}"
718
+ .show="${model.show}"
719
+ endpoint="${this.endpoint}"
720
+ apiVersion="${this.apiVersion}"
721
+ @model-remove="${this._removeModel}"
722
+ @model-move-down="${this._moveModelDown}"
723
+ @model-move-up="${this._moveModelUp}"
724
+ @model-changed="${this.handleModelChanged}"
725
+ @click="${e => this.setCurrentSelection(e, index)}"
726
+ hasParent
626
727
  ></pb-odd-model-editor>
627
- `)}
728
+ `,
729
+ )}
628
730
 
629
731
  </div>
630
732
  </form>
631
733
  <pb-message id="dialog"></pb-message>
632
734
  `;
633
- }
634
-
635
- firstUpdated() {
636
- super.firstUpdated();
637
-
638
- this.hasCustomBehaviour = this.behaviours.indexOf(this.behaviour) < 0;
639
- if (this.hasCustomBehaviour) {
640
- this.shadowRoot.getElementById('custombehaviour').value = this.behaviour;
641
- }
642
- }
643
-
644
- updated(_changedProperties) {
645
- if (_changedProperties.has('show') && this.show) {
646
- this.refreshEditors();
647
- }
648
- }
649
-
650
- refreshEditors() {
651
- console.log('refreshEditors');
652
- // this.shadowRoot.getElementById('predicate').refresh();
653
-
654
- if (this._isGroupOrSequence()) { return console.log("asfdfa"); }
655
-
656
- // this.shadowRoot.getElementById('template').refresh();
657
-
658
- const models = this.shadowRoot.querySelectorAll('pb-odd-model-editor');
659
- for (let i = 0; i < models.length; i++) {
660
- models[i].refreshEditors();
661
- }
662
- const renditions = this.shadowRoot.querySelectorAll('pb-odd-rendition-editor');
663
- for (let i = 0; i < renditions.length; i++) {
664
- renditions[i].refreshEditor();
665
- }
666
- const parameters = this.shadowRoot.querySelectorAll('pb-odd-parameter-editor');
667
- for (let i = 0; i < parameters.length; i++) {
668
- parameters[i].refreshEditor();
669
- }
670
- }
671
-
672
- toggle(e) {
673
- // e.stopPropagation()
674
- // e.preventDefault()
675
-
676
- this.show = !this.show;
677
- this.toggleButtonIcon();
678
-
679
- const oldModel = this.model;
680
- const newModel = Object.assign({}, oldModel, { show: this.show });
681
- this.model = newModel;
682
- this.refreshEditors();
683
- this.dispatchEvent(new CustomEvent('model-changed', { composed: true, bubbles: true, detail: { oldModel, newModel } }));
684
- }
685
-
686
- toggleButtonIcon() {
687
- if (this.show) {
688
- this.icon = 'expand-less';
689
- }
690
- else {
691
- this.icon = 'expand-more';
692
- }
693
- }
694
-
695
- _isModel() {
696
- return this.type === 'model';
697
- }
698
-
699
- _isGroupOrSequence() {
700
- return this.type !== 'model';
701
- }
702
-
703
- static _templateMode(output) {
704
- switch (output) {
705
- case 'latex':
706
- return 'latex';
707
- case 'web':
708
- default:
709
- return 'xml';
710
- }
711
- }
712
-
713
- _changeSelection(e) {
714
- if (e.detail.target == this) return;
715
- e.preventDefault();
716
- e.stopPropagation();
717
- if (this.currentSelection != undefined) {
718
- this.currentSelection.removeAttribute('currentselection');
719
- }
720
- const newSelection = e.detail.target;
721
- newSelection.setAttribute('currentselection', 'true');
722
- this.currentSelection = newSelection;
723
- }
724
-
725
- _requestRemoval(e) {
726
- e.preventDefault();
727
- this.dispatchEvent(new CustomEvent('model-remove'));
728
- }
729
-
730
- /**
731
- * move model down in list
732
- *
733
- * @param e
734
- * @event model-move-down dispatched to request the model to move down
735
- */
736
- _moveDown(e) {
737
- e.preventDefault();
738
- e.stopPropagation();
739
- // this.dispatchEvent(new CustomEvent('model-move-down'));
740
- this.dispatchEvent(new CustomEvent('model-move-down', { composed: true, bubbles: true, detail: { model: this } }));
741
- }
742
-
743
- /**
744
- * move model up in list
745
- *
746
- * @param e
747
- * @event model-move-up dispatched to request the model to move up
748
- */
749
- _moveUp(e) {
750
- e.preventDefault();
751
- e.stopPropagation();
752
- this.dispatchEvent(new CustomEvent('model-move-up'));
753
- }
754
-
755
- _addNested(e) {
756
- const newNestedModel = {
757
- behaviour: 'inline',
758
- css: '',
759
- desc: '',
760
- predicate: '',
761
- type: e instanceof Event ? e.detail.item.getAttribute('value') : e,
762
- output: '',
763
- sourcerend: false,
764
- models: [],
765
- mode: '',
766
- parameters: [],
767
- renditions: [],
768
- template: '',
769
- show: true
770
- };
771
-
772
- const oldModel = this.model;
773
- const models = Array.from(this.model.models);
774
- models.unshift(newNestedModel);
775
- this.model = Object.assign({}, oldModel, { models });
776
-
777
- // important to reset the listbox - otherwise next attempt to use it will fail if value has not changed
778
- // use querySelector here instead of 'this.$' as listbox is in it's own <template>
779
- const modelTypeSelector = this.shadowRoot.querySelector('#modelType')
780
- modelTypeSelector.select("");
781
-
782
- this.dispatchEvent(new CustomEvent('model-changed', { composed: true, bubbles: true, detail: { oldModel, newModel: this.model } }));
783
- }
735
+ }
784
736
 
785
- addModel(newModel) {
786
- if (newModel.type !== 'model') {
787
- console.error('only models can be added to modelSequence or modelGrp');
788
- return;
789
- }
790
- this.model.models.unshift(newModel);
791
- this.requestUpdate();
792
- }
737
+ firstUpdated() {
738
+ super.firstUpdated();
793
739
 
794
- _removeModel(ev) {
795
- console.log('_removeModel ', ev);
796
- ev.stopPropagation();
797
- const { model } = ev.target;
798
- const index = this.model.models.indexOf(model)
799
-
800
- this.shadowRoot.getElementById('dialog')
801
- .confirm(i18n('odd.editor.model.delete-model-label'), i18n('odd.editor.model.delete-model-message'))
802
- .then(() => {
803
- const oldModel = this.model;
804
- const models = Array.from(this.model.models);
805
- models.splice(index, 1);
806
- this.model = Object.assign({}, oldModel, { models });
807
- this.models = models;
808
- this.dispatchEvent(new CustomEvent('model-changed', { composed: true, bubbles: true, detail: { oldModel, newModel: this.model } }));
809
- }, () => null);
740
+ this.hasCustomBehaviour = this.behaviours.indexOf(this.behaviour) < 0;
741
+ if (this.hasCustomBehaviour) {
742
+ this.shadowRoot.getElementById('custombehaviour').value = this.behaviour;
810
743
  }
744
+ }
811
745
 
812
- _moveModelDown(ev) {
813
- console.log('MODEL._moveModelDown ', ev);
814
- ev.stopPropagation();
815
- const { model } = ev.target;
816
- const index = this.model.models.indexOf(model)
817
- if (index === this.model.models.length) {
818
- return;
819
- }
820
- const oldModel = this.model;
821
- const models = Array.from(this.model.models);
822
- models.splice(index, 1);
823
- models.splice(index + 1, 0, model);
824
- this.model = Object.assign({}, oldModel, { models });
825
-
826
- const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index + 1];
827
- this._setCurrentSelection(index + 1, targetModel);
828
-
829
- this.dispatchEvent(new CustomEvent('model-changed', { composed: true, bubbles: true, detail: { oldModel, newModel: this.model } }));
830
- this.requestUpdate();
746
+ updated(_changedProperties) {
747
+ if (_changedProperties.has('show') && this.show) {
748
+ this.refreshEditors();
831
749
  }
750
+ }
832
751
 
833
- _moveModelUp(ev) {
834
- ev.stopPropagation();
835
- const { model } = ev.target;
836
- const index = this.model.models.indexOf(model)
837
- if (index === 0) {
838
- return;
839
- }
840
- const oldModel = this.model;
841
- const models = Array.from(this.model.models);
842
- // remove element from models
843
- models.splice(index, 1);
844
- // add element to new index
845
- models.splice(index - 1, 0, model);
846
- this.model = Object.assign({}, oldModel, { models });
847
-
848
- const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index - 1];
849
- this._setCurrentSelection(index - 1, targetModel);
850
-
851
- this.dispatchEvent(new CustomEvent('model-changed', { composed: true, bubbles: true, detail: { oldModel, newModel: this.model } }));
852
- // this.requestUpdate();
853
- }
752
+ refreshEditors() {
753
+ console.log('refreshEditors');
754
+ // this.shadowRoot.getElementById('predicate').refresh();
854
755
 
855
- handleModelChanged(ev) {
856
- console.log('handleModelChanged ', ev, this);
857
- ev.stopPropagation();
858
- const oldModel = this.model;
859
- const index = this.model.models.indexOf(ev.detail.oldModel);
860
- const models = Array.from(this.model.models);
861
- models.splice(index, 1, ev.detail.newModel);
862
- this.model = Object.assign({}, oldModel, { models });
863
- this.dispatchEvent(new CustomEvent('model-changed', { composed: true, bubbles: true, detail: { oldModel, newModel: this.model } }));
756
+ if (this._isGroupOrSequence()) {
757
+ return console.log('asfdfa');
864
758
  }
865
759
 
760
+ // this.shadowRoot.getElementById('template').refresh();
866
761
 
867
- //todo: setCurrentSelection functions are redundant in model and elementspec components - do better
868
- setCurrentSelection(e, index) {
869
- e.preventDefault();
870
- e.stopPropagation();
871
-
872
- //prevent event if model is already the current one
873
- this._setCurrentSelection(index, e.target);
762
+ const models = this.shadowRoot.querySelectorAll('pb-odd-model-editor');
763
+ for (let i = 0; i < models.length; i++) {
764
+ models[i].refreshEditors();
874
765
  }
875
-
876
- _setCurrentSelection(index, target) {
877
- // console.log('_setCurrentSelection ', target);
878
- const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index];
879
-
880
- if (!targetModel) { return; }
881
-
882
- if (targetModel.hasAttribute('currentselection')) return;
883
-
884
- this.dispatchEvent(new CustomEvent('current-changed', { composed: true, bubbles: true, detail: { target: target } }));
885
- this.requestUpdate();
766
+ const renditions = this.shadowRoot.querySelectorAll('pb-odd-rendition-editor');
767
+ for (let i = 0; i < renditions.length; i++) {
768
+ renditions[i].refreshEditor();
886
769
  }
887
-
888
- _inputDesc(e) {
889
- this.desc = e.composedPath()[0].value;
890
- this._fireModelChanged('desc', this.desc);
770
+ const parameters = this.shadowRoot.querySelectorAll('pb-odd-parameter-editor');
771
+ for (let i = 0; i < parameters.length; i++) {
772
+ parameters[i].refreshEditor();
891
773
  }
892
-
893
- _selectOutput(e) {
894
- this.output = e.composedPath()[0].selected;
895
- this._fireModelChanged('output', this.output);
774
+ }
775
+
776
+ toggle(e) {
777
+ // e.stopPropagation()
778
+ // e.preventDefault()
779
+
780
+ this.show = !this.show;
781
+ this.toggleButtonIcon();
782
+
783
+ const oldModel = this.model;
784
+ const newModel = { ...oldModel, show: this.show };
785
+ this.model = newModel;
786
+ this.refreshEditors();
787
+ this.dispatchEvent(
788
+ new CustomEvent('model-changed', {
789
+ composed: true,
790
+ bubbles: true,
791
+ detail: { oldModel, newModel },
792
+ }),
793
+ );
794
+ }
795
+
796
+ toggleButtonIcon() {
797
+ if (this.show) {
798
+ this.icon = 'expand-less';
799
+ } else {
800
+ this.icon = 'expand-more';
896
801
  }
897
-
898
- _updatePredicate() {
899
- this.predicate = this.shadowRoot.getElementById('predicate').value;
900
- console.log('_updatePredicate ', this.predicate);
901
- this._fireModelChanged('predicate', this.predicate);
802
+ }
803
+
804
+ _isModel() {
805
+ return this.type === 'model';
806
+ }
807
+
808
+ _isGroupOrSequence() {
809
+ return this.type !== 'model';
810
+ }
811
+
812
+ static _templateMode(output) {
813
+ switch (output) {
814
+ case 'latex':
815
+ return 'latex';
816
+ case 'web':
817
+ default:
818
+ return 'xml';
902
819
  }
903
-
904
- _selectBehaviour(ev) {
905
- this.behaviour = ev.composedPath()[0].selected;
906
- this._fireModelChanged('behaviour', this.behaviour);
820
+ }
821
+
822
+ _changeSelection(e) {
823
+ if (e.detail.target == this) return;
824
+ e.preventDefault();
825
+ e.stopPropagation();
826
+ if (this.currentSelection != undefined) {
827
+ this.currentSelection.removeAttribute('currentselection');
907
828
  }
908
-
909
- _inputCss(ev) {
910
- this.css = ev.composedPath()[0].value;
911
- this._fireModelChanged('css', this.css);
829
+ const newSelection = e.detail.target;
830
+ newSelection.setAttribute('currentselection', 'true');
831
+ this.currentSelection = newSelection;
832
+ }
833
+
834
+ _requestRemoval(e) {
835
+ e.preventDefault();
836
+ this.dispatchEvent(new CustomEvent('model-remove'));
837
+ }
838
+
839
+ /**
840
+ * move model down in list
841
+ *
842
+ * @param e
843
+ * @event model-move-down dispatched to request the model to move down
844
+ */
845
+ _moveDown(e) {
846
+ e.preventDefault();
847
+ e.stopPropagation();
848
+ // this.dispatchEvent(new CustomEvent('model-move-down'));
849
+ this.dispatchEvent(
850
+ new CustomEvent('model-move-down', {
851
+ composed: true,
852
+ bubbles: true,
853
+ detail: { model: this },
854
+ }),
855
+ );
856
+ }
857
+
858
+ /**
859
+ * move model up in list
860
+ *
861
+ * @param e
862
+ * @event model-move-up dispatched to request the model to move up
863
+ */
864
+ _moveUp(e) {
865
+ e.preventDefault();
866
+ e.stopPropagation();
867
+ this.dispatchEvent(new CustomEvent('model-move-up'));
868
+ }
869
+
870
+ _addNested(e) {
871
+ const newNestedModel = {
872
+ behaviour: 'inline',
873
+ css: '',
874
+ desc: '',
875
+ predicate: '',
876
+ type: e instanceof Event ? e.detail.item.getAttribute('value') : e,
877
+ output: '',
878
+ sourcerend: false,
879
+ models: [],
880
+ mode: '',
881
+ parameters: [],
882
+ renditions: [],
883
+ template: '',
884
+ show: true,
885
+ };
886
+
887
+ const oldModel = this.model;
888
+ const models = Array.from(this.model.models);
889
+ models.unshift(newNestedModel);
890
+ this.model = { ...oldModel, models };
891
+
892
+ // important to reset the listbox - otherwise next attempt to use it will fail if value has not changed
893
+ // use querySelector here instead of 'this.$' as listbox is in it's own <template>
894
+ const modelTypeSelector = this.shadowRoot.querySelector('#modelType');
895
+ modelTypeSelector.select('');
896
+
897
+ this.dispatchEvent(
898
+ new CustomEvent('model-changed', {
899
+ composed: true,
900
+ bubbles: true,
901
+ detail: { oldModel, newModel: this.model },
902
+ }),
903
+ );
904
+ }
905
+
906
+ addModel(newModel) {
907
+ if (newModel.type !== 'model') {
908
+ console.error('only models can be added to modelSequence or modelGrp');
909
+ return;
912
910
  }
913
-
914
- _inputMode(ev) {
915
- this.mode = ev.composedPath()[0].value;
916
- this._fireModelChanged('mode', this.mode);
911
+ this.model.models.unshift(newModel);
912
+ this.requestUpdate();
913
+ }
914
+
915
+ _removeModel(ev) {
916
+ console.log('_removeModel ', ev);
917
+ ev.stopPropagation();
918
+ const { model } = ev.target;
919
+ const index = this.model.models.indexOf(model);
920
+
921
+ this.shadowRoot
922
+ .getElementById('dialog')
923
+ .confirm(
924
+ i18n('odd.editor.model.delete-model-label'),
925
+ i18n('odd.editor.model.delete-model-message'),
926
+ )
927
+ .then(
928
+ () => {
929
+ const oldModel = this.model;
930
+ const models = Array.from(this.model.models);
931
+ models.splice(index, 1);
932
+ this.model = { ...oldModel, models };
933
+ this.models = models;
934
+ this.dispatchEvent(
935
+ new CustomEvent('model-changed', {
936
+ composed: true,
937
+ bubbles: true,
938
+ detail: { oldModel, newModel: this.model },
939
+ }),
940
+ );
941
+ },
942
+ () => null,
943
+ );
944
+ }
945
+
946
+ _moveModelDown(ev) {
947
+ console.log('MODEL._moveModelDown ', ev);
948
+ ev.stopPropagation();
949
+ const { model } = ev.target;
950
+ const index = this.model.models.indexOf(model);
951
+ if (index === this.model.models.length) {
952
+ return;
917
953
  }
918
-
919
- _updateTemplate(ev) {
920
- this.template = this.shadowRoot.getElementById('template').content;
921
- this._fireModelChanged('template', this.template);
954
+ const oldModel = this.model;
955
+ const models = Array.from(this.model.models);
956
+ models.splice(index, 1);
957
+ models.splice(index + 1, 0, model);
958
+ this.model = { ...oldModel, models };
959
+
960
+ const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index + 1];
961
+ this._setCurrentSelection(index + 1, targetModel);
962
+
963
+ this.dispatchEvent(
964
+ new CustomEvent('model-changed', {
965
+ composed: true,
966
+ bubbles: true,
967
+ detail: { oldModel, newModel: this.model },
968
+ }),
969
+ );
970
+ this.requestUpdate();
971
+ }
972
+
973
+ _moveModelUp(ev) {
974
+ ev.stopPropagation();
975
+ const { model } = ev.target;
976
+ const index = this.model.models.indexOf(model);
977
+ if (index === 0) {
978
+ return;
922
979
  }
923
-
924
- /**
925
- * add a model parameter
926
- *
927
- * @param e
928
- */
929
- _addParameter(e) {
930
- this.parameters.push({ name: "", value: "" });
931
- this._fireModelChanged('parameters', this.parameters);
980
+ const oldModel = this.model;
981
+ const models = Array.from(this.model.models);
982
+ // remove element from models
983
+ models.splice(index, 1);
984
+ // add element to new index
985
+ models.splice(index - 1, 0, model);
986
+ this.model = { ...oldModel, models };
987
+
988
+ const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index - 1];
989
+ this._setCurrentSelection(index - 1, targetModel);
990
+
991
+ this.dispatchEvent(
992
+ new CustomEvent('model-changed', {
993
+ composed: true,
994
+ bubbles: true,
995
+ detail: { oldModel, newModel: this.model },
996
+ }),
997
+ );
998
+ // this.requestUpdate();
999
+ }
1000
+
1001
+ handleModelChanged(ev) {
1002
+ console.log('handleModelChanged ', ev, this);
1003
+ ev.stopPropagation();
1004
+ const oldModel = this.model;
1005
+ const index = this.model.models.indexOf(ev.detail.oldModel);
1006
+ const models = Array.from(this.model.models);
1007
+ models.splice(index, 1, ev.detail.newModel);
1008
+ this.model = { ...oldModel, models };
1009
+ this.dispatchEvent(
1010
+ new CustomEvent('model-changed', {
1011
+ composed: true,
1012
+ bubbles: true,
1013
+ detail: { oldModel, newModel: this.model },
1014
+ }),
1015
+ );
1016
+ }
1017
+
1018
+ // todo: setCurrentSelection functions are redundant in model and elementspec components - do better
1019
+ setCurrentSelection(e, index) {
1020
+ e.preventDefault();
1021
+ e.stopPropagation();
1022
+
1023
+ // prevent event if model is already the current one
1024
+ this._setCurrentSelection(index, e.target);
1025
+ }
1026
+
1027
+ _setCurrentSelection(index, target) {
1028
+ // console.log('_setCurrentSelection ', target);
1029
+ const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index];
1030
+
1031
+ if (!targetModel) {
1032
+ return;
932
1033
  }
933
1034
 
934
- _updateParam(e, index) {
935
- this.parameters[index].name = e.detail.name;
936
- this.parameters[index].value = e.detail.value;
937
- this.parameters[index].set = e.detail.set;
938
- this._fireModelChanged('parameters', this.parameters);
1035
+ if (targetModel.hasAttribute('currentselection')) return;
1036
+
1037
+ this.dispatchEvent(
1038
+ new CustomEvent('current-changed', { composed: true, bubbles: true, detail: { target } }),
1039
+ );
1040
+ this.requestUpdate();
1041
+ }
1042
+
1043
+ _inputDesc(e) {
1044
+ this.desc = e.composedPath()[0].value;
1045
+ this._fireModelChanged('desc', this.desc);
1046
+ }
1047
+
1048
+ _selectOutput(e) {
1049
+ this.output = e.composedPath()[0].selected;
1050
+ this._fireModelChanged('output', this.output);
1051
+ }
1052
+
1053
+ _updatePredicate() {
1054
+ this.predicate = this.shadowRoot.getElementById('predicate').value;
1055
+ console.log('_updatePredicate ', this.predicate);
1056
+ this._fireModelChanged('predicate', this.predicate);
1057
+ }
1058
+
1059
+ _selectBehaviour(ev) {
1060
+ this.behaviour = ev.composedPath()[0].selected;
1061
+ this._fireModelChanged('behaviour', this.behaviour);
1062
+ }
1063
+
1064
+ _inputCss(ev) {
1065
+ this.css = ev.composedPath()[0].value;
1066
+ this._fireModelChanged('css', this.css);
1067
+ }
1068
+
1069
+ _inputMode(ev) {
1070
+ this.mode = ev.composedPath()[0].value;
1071
+ this._fireModelChanged('mode', this.mode);
1072
+ }
1073
+
1074
+ _updateTemplate(ev) {
1075
+ this.template = this.shadowRoot.getElementById('template').content;
1076
+ this._fireModelChanged('template', this.template);
1077
+ }
1078
+
1079
+ /**
1080
+ * add a model parameter
1081
+ *
1082
+ * @param e
1083
+ */
1084
+ _addParameter(e) {
1085
+ this.parameters.push({ name: '', value: '' });
1086
+ this._fireModelChanged('parameters', this.parameters);
1087
+ }
1088
+
1089
+ _updateParam(e, index) {
1090
+ this.parameters[index].name = e.detail.name;
1091
+ this.parameters[index].value = e.detail.value;
1092
+ this.parameters[index].set = e.detail.set;
1093
+ this._fireModelChanged('parameters', this.parameters);
1094
+ }
1095
+
1096
+ /**
1097
+ * remove a parameter
1098
+ * @param e
1099
+ * @param index
1100
+ * @private
1101
+ */
1102
+ _removeParam(e, index) {
1103
+ this.parameters.splice(index, 1);
1104
+ this._fireModelChanged('parameters', this.parameters);
1105
+ }
1106
+
1107
+ /**
1108
+ * add a rendition
1109
+ *
1110
+ * @param ev
1111
+ */
1112
+ _addRendition(ev) {
1113
+ this.renditions.push({
1114
+ scope: '',
1115
+ css: '',
1116
+ });
1117
+ this._fireModelChanged('renditions', this.renditions);
1118
+ }
1119
+
1120
+ _updateRendition(e, index) {
1121
+ this.renditions[index].css = e.detail.css;
1122
+ this.renditions[index].scope = e.detail.scope;
1123
+ this._fireModelChanged('renditions', this.renditions);
1124
+ }
1125
+
1126
+ _removeRendition(e, index) {
1127
+ this.renditions.splice(index, 1);
1128
+ this._fireModelChanged('renditions', this.renditions);
1129
+ }
1130
+
1131
+ _fireModelChanged(prop, value) {
1132
+ const oldModel = this.model;
1133
+ this.model = { ...this.model, [prop]: value };
1134
+ console.log('model changed for %s: %o - %o', prop, value, this.model);
1135
+ this.dispatchEvent(
1136
+ new CustomEvent('model-changed', {
1137
+ composed: true,
1138
+ bubbles: true,
1139
+ detail: { oldModel, newModel: this.model },
1140
+ }),
1141
+ );
1142
+ this.requestUpdate();
1143
+ }
1144
+
1145
+ _copy(ev) {
1146
+ ev.preventDefault();
1147
+ ev.stopPropagation();
1148
+ console.log('odd-model.copy ', ev);
1149
+ console.log('odd-model.copy data', this.model);
1150
+
1151
+ this.dispatchEvent(
1152
+ new CustomEvent('odd-copy', { composed: true, bubbles: true, detail: { model: this.model } }),
1153
+ );
1154
+ }
1155
+
1156
+ _paste(ev) {
1157
+ console.log('model _paste ', ev);
1158
+ this.dispatchEvent(
1159
+ new CustomEvent('odd-paste', { composed: true, bubbles: true, detail: { target: this } }),
1160
+ );
1161
+ }
1162
+
1163
+ _handleCustomBehaviour(e) {
1164
+ this.behaviour = e.composedPath()[0].value;
1165
+ this._fireModelChanged('behaviour', this.behaviour);
1166
+
1167
+ // en-/disable behaviour menu
1168
+ if (this.behaviour === '') {
1169
+ this.behaviour = 'inline';
1170
+ this.hasCustomBehaviour = false;
1171
+ } else {
1172
+ this.hasCustomBehaviour = true;
939
1173
  }
940
-
941
- /**
942
- * remove a parameter
943
- * @param e
944
- * @param index
945
- * @private
946
- */
947
- _removeParam(e, index) {
948
- this.parameters.splice(index, 1);
949
- this._fireModelChanged('parameters', this.parameters);
950
- }
951
-
952
- /**
953
- * add a rendition
954
- *
955
- * @param ev
956
- */
957
- _addRendition(ev) {
958
- this.renditions.push({
959
- scope: '',
960
- css: ''
961
- });
962
- this._fireModelChanged('renditions', this.renditions);
963
- }
964
-
965
- _updateRendition(e, index) {
966
- this.renditions[index].css = e.detail.css;
967
- this.renditions[index].scope = e.detail.scope;
968
- this._fireModelChanged('renditions', this.renditions);
969
- }
970
-
971
- _removeRendition(e, index) {
972
- this.renditions.splice(index, 1);
973
- this._fireModelChanged('renditions', this.renditions);
974
- }
975
-
976
- _fireModelChanged(prop, value) {
977
- const oldModel = this.model;
978
- this.model = Object.assign({}, this.model, { [prop]: value });
979
- console.log('model changed for %s: %o - %o', prop, value, this.model);
980
- this.dispatchEvent(new CustomEvent('model-changed', { composed: true, bubbles: true, detail: { oldModel, newModel: this.model } }));
981
- this.requestUpdate();
982
- }
983
-
984
- _copy(ev) {
985
- ev.preventDefault();
986
- ev.stopPropagation();
987
- console.log('odd-model.copy ', ev);
988
- console.log('odd-model.copy data', this.model);
989
-
990
- this.dispatchEvent(new CustomEvent('odd-copy', { composed: true, bubbles: true, detail: { model: this.model } }));
991
- }
992
-
993
- _paste(ev) {
994
- console.log('model _paste ', ev);
995
- this.dispatchEvent(new CustomEvent('odd-paste', { composed: true, bubbles: true, detail: { target: this } }));
996
- }
997
-
998
-
999
- _handleCustomBehaviour(e) {
1000
- this.behaviour = e.composedPath()[0].value;
1001
- this._fireModelChanged('behaviour', this.behaviour);
1002
-
1003
- // en-/disable behaviour menu
1004
- if (this.behaviour === '') {
1005
- this.behaviour = 'inline';
1006
- this.hasCustomBehaviour = false;
1007
- } else {
1008
- this.hasCustomBehaviour = true;
1009
- }
1010
- this.requestUpdate();
1011
-
1012
- }
1013
-
1014
-
1015
-
1174
+ this.requestUpdate();
1175
+ }
1016
1176
  }
1017
1177
  customElements.define('pb-odd-model-editor', PbOddModelEditor);