@teipublisher/pb-components 2.26.0-next-3.12 → 2.26.0-next-3.13

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