@teipublisher/pb-components 1.26.0 → 1.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/css/gridjs/mermaid.min.css +1 -0
- package/dist/demo/demos.json +4 -1
- package/dist/demo/pb-table-grid.html +17 -0
- package/dist/demo/people.json +35 -0
- package/dist/pb-components-bundle.js +136 -117
- package/dist/pb-elements.json +231 -0
- package/dist/pb-odd-editor.js +23 -14
- package/i18n/common/de.json +8 -1
- package/i18n/common/en.json +11 -3
- package/package.json +2 -1
- package/pb-elements.json +231 -0
- package/src/authority/connectors.js +4 -0
- package/src/authority/reconciliation.js +124 -0
- package/src/pb-components.js +1 -0
- package/src/pb-odd-editor.js +6 -2
- package/src/pb-odd-elementspec-editor.js +2 -0
- package/src/pb-odd-model-editor.js +17 -0
- package/src/pb-odd-parameter-editor.js +12 -5
- package/src/pb-table-column.js +66 -0
- package/src/pb-table-grid.js +212 -0
- package/src/pb-view-annotate.js +21 -6
- package/src/pb-view.js +10 -1
package/dist/pb-elements.json
CHANGED
|
@@ -6661,6 +6661,11 @@
|
|
|
6661
6661
|
"type": "string",
|
|
6662
6662
|
"default": "\"\""
|
|
6663
6663
|
},
|
|
6664
|
+
{
|
|
6665
|
+
"name": "mode",
|
|
6666
|
+
"type": "string",
|
|
6667
|
+
"default": "\"\""
|
|
6668
|
+
},
|
|
6664
6669
|
{
|
|
6665
6670
|
"name": "model",
|
|
6666
6671
|
"type": "object",
|
|
@@ -6771,6 +6776,12 @@
|
|
|
6771
6776
|
"type": "string",
|
|
6772
6777
|
"default": "\"\""
|
|
6773
6778
|
},
|
|
6779
|
+
{
|
|
6780
|
+
"name": "mode",
|
|
6781
|
+
"attribute": "mode",
|
|
6782
|
+
"type": "string",
|
|
6783
|
+
"default": "\"\""
|
|
6784
|
+
},
|
|
6774
6785
|
{
|
|
6775
6786
|
"name": "model",
|
|
6776
6787
|
"attribute": "model",
|
|
@@ -6882,6 +6893,11 @@
|
|
|
6882
6893
|
"type": "string",
|
|
6883
6894
|
"default": "\"\""
|
|
6884
6895
|
},
|
|
6896
|
+
{
|
|
6897
|
+
"name": "set",
|
|
6898
|
+
"type": "boolean",
|
|
6899
|
+
"default": "false"
|
|
6900
|
+
},
|
|
6885
6901
|
{
|
|
6886
6902
|
"name": "behaviour",
|
|
6887
6903
|
"type": "string",
|
|
@@ -6918,6 +6934,12 @@
|
|
|
6918
6934
|
"type": "string",
|
|
6919
6935
|
"default": "\"\""
|
|
6920
6936
|
},
|
|
6937
|
+
{
|
|
6938
|
+
"name": "setParam",
|
|
6939
|
+
"attribute": "set",
|
|
6940
|
+
"type": "boolean",
|
|
6941
|
+
"default": "false"
|
|
6942
|
+
},
|
|
6921
6943
|
{
|
|
6922
6944
|
"name": "behaviour",
|
|
6923
6945
|
"attribute": "behaviour",
|
|
@@ -8923,6 +8945,215 @@
|
|
|
8923
8945
|
}
|
|
8924
8946
|
]
|
|
8925
8947
|
},
|
|
8948
|
+
{
|
|
8949
|
+
"name": "pb-table-column",
|
|
8950
|
+
"path": "./src/pb-table-column.js",
|
|
8951
|
+
"description": "Defines a column within `pb-table-grid`.",
|
|
8952
|
+
"attributes": [
|
|
8953
|
+
{
|
|
8954
|
+
"name": "label",
|
|
8955
|
+
"description": "Column heading to display",
|
|
8956
|
+
"type": "string",
|
|
8957
|
+
"default": "\"no-label\""
|
|
8958
|
+
},
|
|
8959
|
+
{
|
|
8960
|
+
"name": "property",
|
|
8961
|
+
"description": "Name of the JSON property containing the data",
|
|
8962
|
+
"type": "string"
|
|
8963
|
+
},
|
|
8964
|
+
{
|
|
8965
|
+
"name": "sort",
|
|
8966
|
+
"description": "Should the column support sorting?",
|
|
8967
|
+
"type": "boolean",
|
|
8968
|
+
"default": "false"
|
|
8969
|
+
},
|
|
8970
|
+
{
|
|
8971
|
+
"name": "width",
|
|
8972
|
+
"description": "Optional fixed width of the column (e.g. '200px' or '30%')",
|
|
8973
|
+
"type": "string"
|
|
8974
|
+
}
|
|
8975
|
+
],
|
|
8976
|
+
"properties": [
|
|
8977
|
+
{
|
|
8978
|
+
"name": "label",
|
|
8979
|
+
"attribute": "label",
|
|
8980
|
+
"description": "Column heading to display",
|
|
8981
|
+
"type": "string",
|
|
8982
|
+
"default": "\"no-label\""
|
|
8983
|
+
},
|
|
8984
|
+
{
|
|
8985
|
+
"name": "property",
|
|
8986
|
+
"attribute": "property",
|
|
8987
|
+
"description": "Name of the JSON property containing the data",
|
|
8988
|
+
"type": "string"
|
|
8989
|
+
},
|
|
8990
|
+
{
|
|
8991
|
+
"name": "sort",
|
|
8992
|
+
"attribute": "sort",
|
|
8993
|
+
"description": "Should the column support sorting?",
|
|
8994
|
+
"type": "boolean",
|
|
8995
|
+
"default": "false"
|
|
8996
|
+
},
|
|
8997
|
+
{
|
|
8998
|
+
"name": "width",
|
|
8999
|
+
"attribute": "width",
|
|
9000
|
+
"description": "Optional fixed width of the column (e.g. '200px' or '30%')",
|
|
9001
|
+
"type": "string"
|
|
9002
|
+
}
|
|
9003
|
+
]
|
|
9004
|
+
},
|
|
9005
|
+
{
|
|
9006
|
+
"name": "pb-table-grid",
|
|
9007
|
+
"path": "./src/pb-table-grid.js",
|
|
9008
|
+
"description": "A table grid based on [gridjs](https://gridjs.io/), which loads its data from a server endpoint\nspecified in `source`. If `source` is a relative URI, it will be resolved relative to the\nTEI Publisher endpoint.\n\nThe JSON data returned by the endpoint should be an object with two properties:\n\n* `count`: the overall number of rows available on the server\n* `results`: an array containing each record as an object\n\nThe parameters send to the server are as follows:\n\n\nParameter | Description\n---------|----------\nlimit | number of records to return for each page\nstart | start offset from which to return records\norder | the id of the column to sort by\ndir | sort direction: either 'asc' or 'desc'\nsearch | an optional search string entered by the user\n\nTable columns are configured via nested `<pb-table-column>` elements:\n\n```html\n<pb-table-column label=\"Name\" property=\"name\" sort width=\"33%\"></pb-table-column>\n<pb-table-column label=\"Born\" property=\"birth\"></pb-table-column>\n<pb-table-column label=\"Died\" property=\"death\"></pb-table-column>\n```",
|
|
9009
|
+
"attributes": [
|
|
9010
|
+
{
|
|
9011
|
+
"name": "source",
|
|
9012
|
+
"description": "URI of the server-side endpoint to retrieve data from.\nRelative URIs are resolved relative to the configured TEI Publisher endpoint.",
|
|
9013
|
+
"type": "string"
|
|
9014
|
+
},
|
|
9015
|
+
{
|
|
9016
|
+
"name": "css-path",
|
|
9017
|
+
"description": "Path to the gridjs theme CSS files.",
|
|
9018
|
+
"type": "string",
|
|
9019
|
+
"default": "\"../css/gridjs\""
|
|
9020
|
+
},
|
|
9021
|
+
{
|
|
9022
|
+
"name": "resizable",
|
|
9023
|
+
"description": "If specified, columns (without a fixed width) will be resizable.",
|
|
9024
|
+
"type": "boolean",
|
|
9025
|
+
"default": "false"
|
|
9026
|
+
},
|
|
9027
|
+
{
|
|
9028
|
+
"name": "search",
|
|
9029
|
+
"description": "If specified, enable server-side search.",
|
|
9030
|
+
"type": "boolean",
|
|
9031
|
+
"default": "false"
|
|
9032
|
+
},
|
|
9033
|
+
{
|
|
9034
|
+
"name": "per-page",
|
|
9035
|
+
"type": "number",
|
|
9036
|
+
"default": "10"
|
|
9037
|
+
},
|
|
9038
|
+
{
|
|
9039
|
+
"name": "height",
|
|
9040
|
+
"type": "string"
|
|
9041
|
+
},
|
|
9042
|
+
{
|
|
9043
|
+
"name": "subscribe",
|
|
9044
|
+
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
9045
|
+
"type": "string"
|
|
9046
|
+
},
|
|
9047
|
+
{
|
|
9048
|
+
"name": "subscribe-config",
|
|
9049
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to listen to.",
|
|
9050
|
+
"type": "object"
|
|
9051
|
+
},
|
|
9052
|
+
{
|
|
9053
|
+
"name": "emit",
|
|
9054
|
+
"description": "The name of the channel to send events to.",
|
|
9055
|
+
"type": "string"
|
|
9056
|
+
},
|
|
9057
|
+
{
|
|
9058
|
+
"name": "emit-config",
|
|
9059
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to be dispatched.",
|
|
9060
|
+
"type": "object"
|
|
9061
|
+
},
|
|
9062
|
+
{
|
|
9063
|
+
"name": "wait-for",
|
|
9064
|
+
"description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
|
|
9065
|
+
"type": "string"
|
|
9066
|
+
},
|
|
9067
|
+
{
|
|
9068
|
+
"name": "disabled",
|
|
9069
|
+
"description": "Common property to disable the functionality associated with a component.\n`pb-highlight` and `pb-popover` react to this.",
|
|
9070
|
+
"type": "boolean",
|
|
9071
|
+
"default": "false"
|
|
9072
|
+
}
|
|
9073
|
+
],
|
|
9074
|
+
"properties": [
|
|
9075
|
+
{
|
|
9076
|
+
"name": "source",
|
|
9077
|
+
"attribute": "source",
|
|
9078
|
+
"description": "URI of the server-side endpoint to retrieve data from.\nRelative URIs are resolved relative to the configured TEI Publisher endpoint.",
|
|
9079
|
+
"type": "string"
|
|
9080
|
+
},
|
|
9081
|
+
{
|
|
9082
|
+
"name": "cssPath",
|
|
9083
|
+
"attribute": "css-path",
|
|
9084
|
+
"description": "Path to the gridjs theme CSS files.",
|
|
9085
|
+
"type": "string",
|
|
9086
|
+
"default": "\"../css/gridjs\""
|
|
9087
|
+
},
|
|
9088
|
+
{
|
|
9089
|
+
"name": "resizable",
|
|
9090
|
+
"attribute": "resizable",
|
|
9091
|
+
"description": "If specified, columns (without a fixed width) will be resizable.",
|
|
9092
|
+
"type": "boolean",
|
|
9093
|
+
"default": "false"
|
|
9094
|
+
},
|
|
9095
|
+
{
|
|
9096
|
+
"name": "search",
|
|
9097
|
+
"attribute": "search",
|
|
9098
|
+
"description": "If specified, enable server-side search.",
|
|
9099
|
+
"type": "boolean",
|
|
9100
|
+
"default": "false"
|
|
9101
|
+
},
|
|
9102
|
+
{
|
|
9103
|
+
"name": "perPage",
|
|
9104
|
+
"attribute": "per-page",
|
|
9105
|
+
"type": "number",
|
|
9106
|
+
"default": "10"
|
|
9107
|
+
},
|
|
9108
|
+
{
|
|
9109
|
+
"name": "height",
|
|
9110
|
+
"attribute": "height",
|
|
9111
|
+
"type": "string"
|
|
9112
|
+
},
|
|
9113
|
+
{
|
|
9114
|
+
"name": "fixedHeader",
|
|
9115
|
+
"type": "boolean",
|
|
9116
|
+
"default": "false"
|
|
9117
|
+
},
|
|
9118
|
+
{
|
|
9119
|
+
"name": "subscribe",
|
|
9120
|
+
"attribute": "subscribe",
|
|
9121
|
+
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
9122
|
+
"type": "string"
|
|
9123
|
+
},
|
|
9124
|
+
{
|
|
9125
|
+
"name": "subscribeConfig",
|
|
9126
|
+
"attribute": "subscribe-config",
|
|
9127
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to listen to.",
|
|
9128
|
+
"type": "object"
|
|
9129
|
+
},
|
|
9130
|
+
{
|
|
9131
|
+
"name": "emit",
|
|
9132
|
+
"attribute": "emit",
|
|
9133
|
+
"description": "The name of the channel to send events to.",
|
|
9134
|
+
"type": "string"
|
|
9135
|
+
},
|
|
9136
|
+
{
|
|
9137
|
+
"name": "emitConfig",
|
|
9138
|
+
"attribute": "emit-config",
|
|
9139
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to be dispatched.",
|
|
9140
|
+
"type": "object"
|
|
9141
|
+
},
|
|
9142
|
+
{
|
|
9143
|
+
"name": "waitFor",
|
|
9144
|
+
"attribute": "wait-for",
|
|
9145
|
+
"description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
|
|
9146
|
+
"type": "string"
|
|
9147
|
+
},
|
|
9148
|
+
{
|
|
9149
|
+
"name": "disabled",
|
|
9150
|
+
"attribute": "disabled",
|
|
9151
|
+
"description": "Common property to disable the functionality associated with a component.\n`pb-highlight` and `pb-popover` react to this.",
|
|
9152
|
+
"type": "boolean",
|
|
9153
|
+
"default": "false"
|
|
9154
|
+
}
|
|
9155
|
+
]
|
|
9156
|
+
},
|
|
8926
9157
|
{
|
|
8927
9158
|
"name": "pb-tabs",
|
|
8928
9159
|
"path": "./src/pb-tabs.js",
|
package/dist/pb-odd-editor.js
CHANGED
|
@@ -12,7 +12,7 @@ import{h as e,o as t,F as o,D as i,E as s,H as r,l as a,f as n,t as d,g as l}fro
|
|
|
12
12
|
* subject to an additional IP rights grant found at
|
|
13
13
|
* http://polymer.github.io/PATENTS.txt
|
|
14
14
|
*/
|
|
15
|
-
const S=(e,t)=>{const o=e.startNode.parentNode,i=void 0===t?e.endNode:t.startNode,s=o.insertBefore(g(),i);o.insertBefore(g(),i);const r=new b(e.options);return r.insertAfterNode(s),r},C=(e,t)=>(e.setValue(t),e.commit(),e),k=(e,t,o)=>{const i=e.startNode.parentNode,s=o?o.startNode:e.endNode,r=t.endNode.nextSibling;r!==s&&v(i,t.startNode,r,s)},A=e=>{f(e.startNode.parentNode,e.startNode,e.endNode.nextSibling)},
|
|
15
|
+
const S=(e,t)=>{const o=e.startNode.parentNode,i=void 0===t?e.endNode:t.startNode,s=o.insertBefore(g(),i);o.insertBefore(g(),i);const r=new b(e.options);return r.insertAfterNode(s),r},C=(e,t)=>(e.setValue(t),e.commit(),e),k=(e,t,o)=>{const i=e.startNode.parentNode,s=o?o.startNode:e.endNode,r=t.endNode.nextSibling;r!==s&&v(i,t.startNode,r,s)},A=e=>{f(e.startNode.parentNode,e.startNode,e.endNode.nextSibling)},M=(e,t,o)=>{const i=new Map;for(let s=t;s<=o;s++)i.set(e[s],s);return i},R=new WeakMap,I=new WeakMap,B=u((e,t,o)=>{let i;return void 0===o?o=t:void 0!==t&&(i=t),t=>{if(!(t instanceof b))throw new Error("repeat can only be used in text bindings");const s=R.get(t)||[],r=I.get(t)||[],a=[],n=[],d=[];let l,c,p=0;for(const t of e)d[p]=i?i(t,p):p,n[p]=o(t,p),p++;let h=0,m=s.length-1,u=0,g=n.length-1;for(;h<=m&&u<=g;)if(null===s[h])h++;else if(null===s[m])m--;else if(r[h]===d[u])a[u]=C(s[h],n[u]),h++,u++;else if(r[m]===d[g])a[g]=C(s[m],n[g]),m--,g--;else if(r[h]===d[g])a[g]=C(s[h],n[g]),k(t,s[h],a[g+1]),h++,g--;else if(r[m]===d[u])a[u]=C(s[m],n[u]),k(t,s[m],s[h]),m--,u++;else if(void 0===l&&(l=M(d,u,g),c=M(r,h,m)),l.has(r[h]))if(l.has(r[m])){const e=c.get(d[u]),o=void 0!==e?s[e]:null;if(null===o){const e=S(t,s[h]);C(e,n[u]),a[u]=e}else a[u]=C(o,n[u]),k(t,o,s[h]),s[e]=null;u++}else A(s[m]),m--;else A(s[h]),h++;for(;u<=g;){const e=S(t,a[g+1]);C(e,n[u]),a[u++]=e}for(;h<=m;){const e=s[h++];null!==e&&A(e)}R.set(t,a),I.set(t,d)}}),P=new WeakMap,T=u(e=>t=>{const o=P.get(t);if(void 0===e&&t instanceof w){if(void 0!==o||!P.has(t)){const e=t.committer.name;t.committer.element.removeAttribute(e)}}else e!==o&&t.setValue(e);P.set(t,e)}),z=e`<dom-module id="lumo-tab" theme-for="vaadin-tab">
|
|
16
16
|
<template>
|
|
17
17
|
<style>
|
|
18
18
|
:host {
|
|
@@ -234,18 +234,18 @@ const S=(e,t)=>{const o=e.startNode.parentNode,i=void 0===t?e.endNode:t.startNod
|
|
|
234
234
|
}
|
|
235
235
|
</style>
|
|
236
236
|
</template>
|
|
237
|
-
</dom-module>`;document.head.appendChild(
|
|
237
|
+
</dom-module>`;document.head.appendChild(z.content);
|
|
238
238
|
/**
|
|
239
239
|
@license
|
|
240
240
|
Copyright (c) 2017 Vaadin Ltd.
|
|
241
241
|
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
242
242
|
*/
|
|
243
|
-
const
|
|
243
|
+
const O=e=>class extends e{static get properties(){return{_hasVaadinItemMixin:{value:!0},disabled:{type:Boolean,value:!1,observer:"_disabledChanged",reflectToAttribute:!0},selected:{type:Boolean,value:!1,reflectToAttribute:!0,observer:"_selectedChanged"},_value:String}}get value(){return void 0!==this._value?this._value:this.textContent.trim()}set value(e){this._value=e}ready(){super.ready();const e=this.getAttribute("value");null!==e&&(this.value=e),this.addEventListener("focus",e=>this._setFocused(!0),!0),this.addEventListener("blur",e=>this._setFocused(!1),!0),this.addEventListener("mousedown",e=>{this._setActive(this._mousedown=!0);const t=()=>{this._setActive(this._mousedown=!1),document.removeEventListener("mouseup",t)};document.addEventListener("mouseup",t)}),this.addEventListener("keydown",e=>this._onKeydown(e)),this.addEventListener("keyup",e=>this._onKeyup(e))}disconnectedCallback(){super.disconnectedCallback(),this.hasAttribute("active")&&this._setFocused(!1)}_selectedChanged(e){this.setAttribute("aria-selected",e)}_disabledChanged(e){e?(this.selected=!1,this.setAttribute("aria-disabled","true"),this.blur()):this.removeAttribute("aria-disabled")}_setFocused(e){e?(this.setAttribute("focused",""),this._mousedown||this.setAttribute("focus-ring","")):(this.removeAttribute("focused"),this.removeAttribute("focus-ring"),this._setActive(!1))}_setActive(e){e?this.setAttribute("active",""):this.removeAttribute("active")}_onKeydown(e){/^( |SpaceBar|Enter)$/.test(e.key)&&!e.defaultPrevented&&(e.preventDefault(),this._setActive(!0))}_onKeyup(e){this.hasAttribute("active")&&(this._setActive(!1),this.click())}}
|
|
244
244
|
/**
|
|
245
245
|
@license
|
|
246
246
|
Copyright (c) 2017 Vaadin Ltd.
|
|
247
247
|
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
248
|
-
*/;class q extends(c(p(
|
|
248
|
+
*/;class q extends(c(p(O(t)))){static get template(){return e`
|
|
249
249
|
<slot></slot>
|
|
250
250
|
`}static get is(){return"vaadin-tab"}static get version(){return"3.2.0"}ready(){super.ready(),this.setAttribute("role","tab")}_onKeyup(e){const t=this.hasAttribute("active");if(super._onKeyup(e),t){const e=this.querySelector("a");e&&e.click()}}}customElements.define(q.is,q);const L=e`<dom-module id="lumo-tabs" theme-for="vaadin-tabs">
|
|
251
251
|
<template>
|
|
@@ -621,7 +621,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
621
621
|
}
|
|
622
622
|
.wrapper{
|
|
623
623
|
display:grid;
|
|
624
|
-
grid-template-columns:150px auto 50px;
|
|
624
|
+
grid-template-columns:150px auto 50px 50px;
|
|
625
625
|
grid-column-gap:20px;
|
|
626
626
|
grid-row-gap:20px;
|
|
627
627
|
margin-bottom:10px;
|
|
@@ -629,8 +629,9 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
629
629
|
paper-dropdown-menu{
|
|
630
630
|
align-self:start;
|
|
631
631
|
}
|
|
632
|
-
paper-icon-button{
|
|
633
|
-
align-self:center;
|
|
632
|
+
paper-icon-button, paper-checkbox {
|
|
633
|
+
align-self: center;
|
|
634
|
+
margin-top: 16px;
|
|
634
635
|
}
|
|
635
636
|
`}render(){return x`
|
|
636
637
|
<div class="wrapper">
|
|
@@ -644,12 +645,12 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
644
645
|
code="${this.value}"
|
|
645
646
|
linter="${this.endpoint}/${$(this.apiVersion,"1.0.0")?"modules/editor.xql":"api/lint"}"
|
|
646
647
|
apiVersion="${this.apiVersion}"></pb-code-editor>
|
|
647
|
-
|
|
648
|
+
<paper-checkbox id="set" ?checked="${this.setParam}" @change="${this._handleCodeChange}">set</paper-checkbox>
|
|
648
649
|
<paper-icon-button @click="${this._delete}" icon="delete" title="delete this parameter"></paper-icon-button>
|
|
649
650
|
</div>
|
|
650
651
|
|
|
651
652
|
|
|
652
|
-
`}static get properties(){return{name:{type:String,reflect:!0},value:{type:String,reflect:!0},behaviour:{type:String},parameters:{type:Object},_currentParameters:{type:Array},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.name="",this.value="",this.behaviour="",this.currentParameters=[],this.parameters={"":[],alternate:["default","alternate","persistent"],anchor:["content","id"],block:["content"],body:["content"],break:["content","type","label"],cell:["content"],cit:["content","source"],document:["content"],figure:["content","title"],graphic:["content","url","width","height","scale","title"],heading:["content","level"],inline:["content"],link:["content","uri","target"],list:["content","type"],listItem:["content","n"],metadata:["content"],note:["content","place","label"],omit:[],paragraph:["content"],row:["content"],section:["content"],table:["content"],text:["content"],title:["content"],webcomponent:["content","name"]},this.selected="",this.endpoint=""}connectedCallback(){super.connectedCallback(),this.value=this.value.trim(),this.dispatchEvent(new CustomEvent("parameter-connected",{composed:!0,bubbles:!0,detail:{target:this}}))}attributeChangedCallback(e,t,o){super.attributeChangedCallback(e,t,o),"behaviour"===e&&(this._currentParameters=this.parameters[o])}firstUpdated(e){this.selected=this.parameters[this.behaviour]||[],this.requestUpdate(),this.shadowRoot.getElementById("combo").addEventListener("focused-changed",this._handleCodeChange.bind(this)),this.shadowRoot.getElementById("editor").addEventListener("code-changed",this._handleCodeChange.bind(this))}refreshEditor(){const e=this.shadowRoot.getElementById("editor");e&&e.refresh()}_delete(e){console.log("parameter delete ",e),e.preventDefault(),this.dispatchEvent(new CustomEvent("parameter-remove",{}))}_handleCodeChange(e){console.log("_handleCodeChange ",e),this.value=this.shadowRoot.getElementById("editor").getSource(),this.name=this.shadowRoot.getElementById("combo").text,this.dispatchEvent(new CustomEvent("parameter-changed",{composed:!0,bubbles:!0,detail:{name:this.name,value:this.value}}))}}customElements.define("pb-odd-parameter-editor",U);class F extends y{static get styles(){return _`
|
|
653
|
+
`}static get properties(){return{name:{type:String,reflect:!0},value:{type:String,reflect:!0},behaviour:{type:String},parameters:{type:Object},setParam:{type:Boolean,attribute:"set"},_currentParameters:{type:Array},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.name="",this.value="",this.setParam=!1,this.behaviour="",this.currentParameters=[],this.parameters={"":[],alternate:["default","alternate","persistent"],anchor:["content","id"],block:["content"],body:["content"],break:["content","type","label"],cell:["content"],cit:["content","source"],document:["content"],figure:["content","title"],graphic:["content","url","width","height","scale","title"],heading:["content","level"],inline:["content"],link:["content","uri","target"],list:["content","type"],listItem:["content","n"],metadata:["content"],note:["content","place","label"],omit:[],paragraph:["content"],row:["content"],section:["content"],table:["content"],text:["content"],title:["content"],webcomponent:["content","name"]},this.selected="",this.endpoint=""}connectedCallback(){super.connectedCallback(),this.value=this.value.trim(),this.dispatchEvent(new CustomEvent("parameter-connected",{composed:!0,bubbles:!0,detail:{target:this}}))}attributeChangedCallback(e,t,o){super.attributeChangedCallback(e,t,o),"behaviour"===e&&(this._currentParameters=this.parameters[o])}firstUpdated(e){this.selected=this.parameters[this.behaviour]||[],this.requestUpdate(),this.shadowRoot.getElementById("combo").addEventListener("focused-changed",this._handleCodeChange.bind(this)),this.shadowRoot.getElementById("editor").addEventListener("code-changed",this._handleCodeChange.bind(this))}refreshEditor(){const e=this.shadowRoot.getElementById("editor");e&&e.refresh()}_delete(e){console.log("parameter delete ",e),e.preventDefault(),this.dispatchEvent(new CustomEvent("parameter-remove",{}))}_handleCodeChange(e){console.log("_handleCodeChange ",e),this.value=this.shadowRoot.getElementById("editor").getSource(),this.name=this.shadowRoot.getElementById("combo").text,this.setParam=this.shadowRoot.getElementById("set").checked,this.dispatchEvent(new CustomEvent("parameter-changed",{composed:!0,bubbles:!0,detail:{name:this.name,value:this.value,set:this.setParam}}))}}customElements.define("pb-odd-parameter-editor",U);class F extends y{static get styles(){return _`
|
|
653
654
|
:host {
|
|
654
655
|
display: flex;
|
|
655
656
|
flex-direction:column;
|
|
@@ -829,7 +830,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
829
830
|
pb-code-editor {
|
|
830
831
|
margin-bottom: 20px;
|
|
831
832
|
}
|
|
832
|
-
`}static get properties(){return{behaviour:{type:String},predicate:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},type:{type:String,reflect:!0},template:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},output:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},css:{type:String,converter:(e,t)=>"null"===e.toLowerCase()?"":e},model:{type:Object},models:{type:Array},parameters:{type:Array},renditions:{type:Array},desc:{type:String,converter:(e,t)=>"null"===e.toLowerCase()?"":e},sourcerend:{type:String},show:{type:Boolean,reflect:!0},outputs:{type:Array},behaviours:{type:Array},icon:{type:String},open:{type:String},hasCustomBehaviour:{type:Boolean},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.behaviour="inline",this.predicate="",this.type="",this.template="",this.output="",this.css="",this.model={},this.model.models=[],this.parameters=[],this.renditions=[],this.desc="",this.sourcerend="",this.show=!1,this.outputs=["","web","print","epub","fo","latex","plain"],this.parentModel=[],this.behaviours=["alternate","anchor","block","body","break","cell","cit","document","figure","graphic","heading","inline","link","list","listItem","metadata","note","omit","paragraph","pass-through","row","section","table","text","title","webcomponent"],this.icon="expand-more",this.hasCustomBehaviour=!1}render(){return x`
|
|
833
|
+
`}static get properties(){return{behaviour:{type:String},predicate:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},type:{type:String,reflect:!0},template:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},output:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},css:{type:String,converter:(e,t)=>"null"===e.toLowerCase()?"":e},mode:{type:String},model:{type:Object},models:{type:Array},parameters:{type:Array},renditions:{type:Array},desc:{type:String,converter:(e,t)=>"null"===e.toLowerCase()?"":e},sourcerend:{type:String},show:{type:Boolean,reflect:!0},outputs:{type:Array},behaviours:{type:Array},icon:{type:String},open:{type:String},hasCustomBehaviour:{type:Boolean},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.behaviour="inline",this.predicate="",this.type="",this.template="",this.output="",this.css="",this.mode="",this.model={},this.model.models=[],this.parameters=[],this.renditions=[],this.desc="",this.sourcerend="",this.show=!1,this.outputs=["","web","print","epub","fo","latex","plain"],this.parentModel=[],this.behaviours=["alternate","anchor","block","body","break","cell","cit","document","figure","graphic","heading","inline","link","list","listItem","metadata","note","omit","paragraph","pass-through","row","section","table","text","title","webcomponent"],this.icon="expand-more",this.hasCustomBehaviour=!1}render(){return x`
|
|
833
834
|
<form>
|
|
834
835
|
<header>
|
|
835
836
|
<h4>
|
|
@@ -918,6 +919,11 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
918
919
|
placeholder="${d("odd.editor.model.css-class-placeholder")}"
|
|
919
920
|
label="CSS Class"
|
|
920
921
|
@change="${this._inputCss}"></paper-input>
|
|
922
|
+
|
|
923
|
+
<paper-input id="mode" .value="${this.mode}"
|
|
924
|
+
placeholder="${d("odd.editor.model.mode-placeholder")}"
|
|
925
|
+
label="Mode"
|
|
926
|
+
@change="${this._inputMode}"></paper-input>
|
|
921
927
|
|
|
922
928
|
<pb-code-editor id="template"
|
|
923
929
|
code="${this.template}"
|
|
@@ -939,6 +945,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
939
945
|
behaviour="${this.behaviour}"
|
|
940
946
|
name="${e.name}"
|
|
941
947
|
value="${e.value}"
|
|
948
|
+
?set="${e.set}"
|
|
942
949
|
endpoint="${this.endpoint}"
|
|
943
950
|
apiVersion="${this.apiVersion}"
|
|
944
951
|
@parameter-remove="${e=>this._removeParam(e,t)}"
|
|
@@ -978,6 +985,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
978
985
|
type="${e.type}"
|
|
979
986
|
output="${e.output}"
|
|
980
987
|
css="${e.css}"
|
|
988
|
+
mode="${e.mode}"
|
|
981
989
|
.model="${e}"
|
|
982
990
|
.parameters="${e.parameters}"
|
|
983
991
|
desc="${e.desc}"
|
|
@@ -999,7 +1007,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
999
1007
|
</div>
|
|
1000
1008
|
</form>
|
|
1001
1009
|
<pb-message id="dialog"></pb-message>
|
|
1002
|
-
`}firstUpdated(){super.firstUpdated(),this.hasCustomBehaviour=this.behaviours.indexOf(this.behaviour)<0,this.hasCustomBehaviour&&(this.shadowRoot.getElementById("custombehaviour").value=this.behaviour)}updated(e){e.has("show")&&this.show&&this.refreshEditors()}refreshEditors(){if(console.log("refreshEditors"),this.shadowRoot.getElementById("predicate").refresh(),this._isGroupOrSequence())return console.log("asfdfa");this.shadowRoot.getElementById("template").refresh();const e=this.shadowRoot.querySelectorAll("pb-odd-model-editor");for(let t=0;t<e.length;t++)e[t].refreshEditors();const t=this.shadowRoot.querySelectorAll("pb-odd-rendition-editor");for(let e=0;e<t.length;e++)t[e].refreshEditor();const o=this.shadowRoot.querySelectorAll("pb-odd-parameter-editor");for(let e=0;e<o.length;e++)o[e].refreshEditor()}toggle(e){this.show=!this.show,this.toggleButtonIcon();const t=this.model,o=Object.assign({},t,{show:this.show});this.model=o,this.refreshEditors(),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:t,newModel:o}}))}toggleButtonIcon(){this.show?this.icon="expand-less":this.icon="expand-more"}_isModel(){return"model"===this.type}_isGroupOrSequence(){return"model"!==this.type}static _templateMode(e){switch(e){case"latex":return"latex";case"web":default:return"xml"}}_changeSelection(e){if(e.detail.target==this)return;e.preventDefault(),e.stopPropagation(),null!=this.currentSelection&&this.currentSelection.removeAttribute("currentselection");const t=e.detail.target;t.setAttribute("currentselection","true"),this.currentSelection=t}_requestRemoval(e){e.preventDefault(),this.dispatchEvent(new CustomEvent("model-remove"))}_moveDown(e){e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent("model-move-down",{composed:!0,bubbles:!0,detail:{model:this}}))}_moveUp(e){e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent("model-move-up"))}_addNested(e){const t={behaviour:"inline",css:"",desc:"",predicate:"",type:e.detail.item.getAttribute("value"),output:"",sourcerend:!1,models:[],parameters:[],renditions:[],template:"",show:!0},o=this.model,i=Array.from(this.model.models);i.unshift(t),this.model=Object.assign({},o,{models:i});this.shadowRoot.querySelector("#modelType").select(""),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:o,newModel:this.model}}))}_removeModel(e){console.log("_removeModel ",e),e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);this.shadowRoot.getElementById("dialog").confirm(l("odd.editor.model.delete-model-label"),l("odd.editor.model.delete-model-message")).then(()=>{const e=this.model,t=Array.from(this.model.models);t.splice(o,1),this.model=Object.assign({},e,{models:t}),this.models=t,this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:e,newModel:this.model}}))},()=>null)}_moveModelDown(e){console.log("MODEL._moveModelDown ",e),e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);if(o===this.model.models.length)return;const i=this.model,s=Array.from(this.model.models);s.splice(o,1),s.splice(o+1,0,t),this.model=Object.assign({},i,{models:s});const r=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o+1];this._setCurrentSelection(o+1,r),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:i,newModel:this.model}})),this.requestUpdate()}_moveModelUp(e){e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);if(0===o)return;const i=this.model,s=Array.from(this.model.models);s.splice(o,1),s.splice(o-1,0,t),this.model=Object.assign({},i,{models:s});const r=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o-1];this._setCurrentSelection(o-1,r),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:i,newModel:this.model}}))}handleModelChanged(e){console.log("handleModelChanged ",e,this),e.stopPropagation();const t=this.model,o=this.model.models.indexOf(e.detail.oldModel),i=Array.from(this.model.models);i.splice(o,1,e.detail.newModel),this.model=Object.assign({},t,{models:i}),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:t,newModel:this.model}}))}setCurrentSelection(e,t){e.preventDefault(),e.stopPropagation(),this._setCurrentSelection(t,e.target)}_setCurrentSelection(e,t){const o=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[e];o&&(o.hasAttribute("currentselection")||(this.dispatchEvent(new CustomEvent("current-changed",{composed:!0,bubbles:!0,detail:{target:t}})),this.requestUpdate()))}_inputDesc(e){this.desc=e.composedPath()[0].value,this._fireModelChanged("desc",this.desc)}_selectOutput(e){this.output=e.composedPath()[0].selected,this._fireModelChanged("output",this.output)}_updatePredicate(e){this.predicate=this.shadowRoot.getElementById("predicate").getSource(),console.log("_updatePredicate ",this.predicate),this._fireModelChanged("predicate",this.predicate)}_selectBehaviour(e){this.behaviour=e.composedPath()[0].selected,this._fireModelChanged("behaviour",this.behaviour)}_inputCss(e){this.css=e.composedPath()[0].value,this._fireModelChanged("css",this.css)}_updateTemplate(e){this.template=this.shadowRoot.getElementById("template").getSource(),this._fireModelChanged("template",this.template)}_addParameter(e){this.parameters.push({name:"",value:""}),this._fireModelChanged("parameters",this.parameters)}_updateParam(e,t){this.parameters[t].name=e.detail.name,this.parameters[t].value=e.detail.value,this._fireModelChanged("parameters",this.parameters)}_removeParam(e,t){this.parameters.splice(t,1),this._fireModelChanged("parameters",this.parameters)}_addRendition(e){this.renditions.push({scope:"",css:""}),this._fireModelChanged("renditions",this.renditions)}_updateRendition(e,t){this.renditions[t].css=e.detail.css,this.renditions[t].scope=e.detail.scope,this._fireModelChanged("renditions",this.renditions)}_removeRendition(e,t){this.renditions.splice(t,1),this._fireModelChanged("renditions",this.renditions)}_fireModelChanged(e,t){const o=this.model;this.model=Object.assign({},this.model,{[e]:t}),console.log("model changed for %s: %o - %o",e,t,this.model),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:o,newModel:this.model}})),this.requestUpdate()}_copy(e){e.preventDefault(),e.stopPropagation(),console.log("odd-model.copy ",e),console.log("odd-model.copy data",this.model),this.dispatchEvent(new CustomEvent("odd-copy",{composed:!0,bubbles:!0,detail:{model:this.model}}))}_paste(e){console.log("model _paste ",e),this.dispatchEvent(new CustomEvent("odd-paste",{composed:!0,bubbles:!0,detail:{target:this}}))}_handleCustomBehaviour(e){this.behaviour=e.composedPath()[0].value,this._fireModelChanged("behaviour",this.behaviour),""===this.behaviour?(this.behaviour="inline",this.hasCustomBehaviour=!1):this.hasCustomBehaviour=!0,this.requestUpdate()}}customElements.define("pb-odd-model-editor",F);class H extends y{static get styles(){return _`
|
|
1010
|
+
`}firstUpdated(){super.firstUpdated(),this.hasCustomBehaviour=this.behaviours.indexOf(this.behaviour)<0,this.hasCustomBehaviour&&(this.shadowRoot.getElementById("custombehaviour").value=this.behaviour)}updated(e){e.has("show")&&this.show&&this.refreshEditors()}refreshEditors(){if(console.log("refreshEditors"),this.shadowRoot.getElementById("predicate").refresh(),this._isGroupOrSequence())return console.log("asfdfa");this.shadowRoot.getElementById("template").refresh();const e=this.shadowRoot.querySelectorAll("pb-odd-model-editor");for(let t=0;t<e.length;t++)e[t].refreshEditors();const t=this.shadowRoot.querySelectorAll("pb-odd-rendition-editor");for(let e=0;e<t.length;e++)t[e].refreshEditor();const o=this.shadowRoot.querySelectorAll("pb-odd-parameter-editor");for(let e=0;e<o.length;e++)o[e].refreshEditor()}toggle(e){this.show=!this.show,this.toggleButtonIcon();const t=this.model,o=Object.assign({},t,{show:this.show});this.model=o,this.refreshEditors(),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:t,newModel:o}}))}toggleButtonIcon(){this.show?this.icon="expand-less":this.icon="expand-more"}_isModel(){return"model"===this.type}_isGroupOrSequence(){return"model"!==this.type}static _templateMode(e){switch(e){case"latex":return"latex";case"web":default:return"xml"}}_changeSelection(e){if(e.detail.target==this)return;e.preventDefault(),e.stopPropagation(),null!=this.currentSelection&&this.currentSelection.removeAttribute("currentselection");const t=e.detail.target;t.setAttribute("currentselection","true"),this.currentSelection=t}_requestRemoval(e){e.preventDefault(),this.dispatchEvent(new CustomEvent("model-remove"))}_moveDown(e){e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent("model-move-down",{composed:!0,bubbles:!0,detail:{model:this}}))}_moveUp(e){e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent("model-move-up"))}_addNested(e){const t={behaviour:"inline",css:"",desc:"",predicate:"",type:e.detail.item.getAttribute("value"),output:"",sourcerend:!1,models:[],parameters:[],renditions:[],template:"",show:!0},o=this.model,i=Array.from(this.model.models);i.unshift(t),this.model=Object.assign({},o,{models:i});this.shadowRoot.querySelector("#modelType").select(""),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:o,newModel:this.model}}))}_removeModel(e){console.log("_removeModel ",e),e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);this.shadowRoot.getElementById("dialog").confirm(l("odd.editor.model.delete-model-label"),l("odd.editor.model.delete-model-message")).then(()=>{const e=this.model,t=Array.from(this.model.models);t.splice(o,1),this.model=Object.assign({},e,{models:t}),this.models=t,this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:e,newModel:this.model}}))},()=>null)}_moveModelDown(e){console.log("MODEL._moveModelDown ",e),e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);if(o===this.model.models.length)return;const i=this.model,s=Array.from(this.model.models);s.splice(o,1),s.splice(o+1,0,t),this.model=Object.assign({},i,{models:s});const r=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o+1];this._setCurrentSelection(o+1,r),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:i,newModel:this.model}})),this.requestUpdate()}_moveModelUp(e){e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);if(0===o)return;const i=this.model,s=Array.from(this.model.models);s.splice(o,1),s.splice(o-1,0,t),this.model=Object.assign({},i,{models:s});const r=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o-1];this._setCurrentSelection(o-1,r),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:i,newModel:this.model}}))}handleModelChanged(e){console.log("handleModelChanged ",e,this),e.stopPropagation();const t=this.model,o=this.model.models.indexOf(e.detail.oldModel),i=Array.from(this.model.models);i.splice(o,1,e.detail.newModel),this.model=Object.assign({},t,{models:i}),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:t,newModel:this.model}}))}setCurrentSelection(e,t){e.preventDefault(),e.stopPropagation(),this._setCurrentSelection(t,e.target)}_setCurrentSelection(e,t){const o=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[e];o&&(o.hasAttribute("currentselection")||(this.dispatchEvent(new CustomEvent("current-changed",{composed:!0,bubbles:!0,detail:{target:t}})),this.requestUpdate()))}_inputDesc(e){this.desc=e.composedPath()[0].value,this._fireModelChanged("desc",this.desc)}_selectOutput(e){this.output=e.composedPath()[0].selected,this._fireModelChanged("output",this.output)}_updatePredicate(e){this.predicate=this.shadowRoot.getElementById("predicate").getSource(),console.log("_updatePredicate ",this.predicate),this._fireModelChanged("predicate",this.predicate)}_selectBehaviour(e){this.behaviour=e.composedPath()[0].selected,this._fireModelChanged("behaviour",this.behaviour)}_inputCss(e){this.css=e.composedPath()[0].value,this._fireModelChanged("css",this.css)}_inputMode(e){this.mode=e.composedPath()[0].value,this._fireModelChanged("mode",this.mode)}_updateTemplate(e){this.template=this.shadowRoot.getElementById("template").getSource(),this._fireModelChanged("template",this.template)}_addParameter(e){this.parameters.push({name:"",value:""}),this._fireModelChanged("parameters",this.parameters)}_updateParam(e,t){this.parameters[t].name=e.detail.name,this.parameters[t].value=e.detail.value,this.parameters[t].set=e.detail.set,this._fireModelChanged("parameters",this.parameters)}_removeParam(e,t){this.parameters.splice(t,1),this._fireModelChanged("parameters",this.parameters)}_addRendition(e){this.renditions.push({scope:"",css:""}),this._fireModelChanged("renditions",this.renditions)}_updateRendition(e,t){this.renditions[t].css=e.detail.css,this.renditions[t].scope=e.detail.scope,this._fireModelChanged("renditions",this.renditions)}_removeRendition(e,t){this.renditions.splice(t,1),this._fireModelChanged("renditions",this.renditions)}_fireModelChanged(e,t){const o=this.model;this.model=Object.assign({},this.model,{[e]:t}),console.log("model changed for %s: %o - %o",e,t,this.model),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:o,newModel:this.model}})),this.requestUpdate()}_copy(e){e.preventDefault(),e.stopPropagation(),console.log("odd-model.copy ",e),console.log("odd-model.copy data",this.model),this.dispatchEvent(new CustomEvent("odd-copy",{composed:!0,bubbles:!0,detail:{model:this.model}}))}_paste(e){console.log("model _paste ",e),this.dispatchEvent(new CustomEvent("odd-paste",{composed:!0,bubbles:!0,detail:{target:this}}))}_handleCustomBehaviour(e){this.behaviour=e.composedPath()[0].value,this._fireModelChanged("behaviour",this.behaviour),""===this.behaviour?(this.behaviour="inline",this.hasCustomBehaviour=!1):this.hasCustomBehaviour=!0,this.requestUpdate()}}customElements.define("pb-odd-model-editor",F);class H extends y{static get styles(){return _`
|
|
1003
1011
|
:host {
|
|
1004
1012
|
display: block;
|
|
1005
1013
|
padding: 4px 10px;
|
|
@@ -1103,6 +1111,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
1103
1111
|
type="${e.type}"
|
|
1104
1112
|
output="${e.output}"
|
|
1105
1113
|
css="${e.css}"
|
|
1114
|
+
mode="${e.mode}"
|
|
1106
1115
|
.model="${e}"
|
|
1107
1116
|
.parameters="${e.parameters}"
|
|
1108
1117
|
desc="${e.desc}"
|
|
@@ -1121,7 +1130,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
1121
1130
|
`)}
|
|
1122
1131
|
</div>
|
|
1123
1132
|
<pb-message id="dialog"></pb-message>
|
|
1124
|
-
`}addModel(e){this.models.unshift(e),this.requestUpdate()}_addModel(e){console.log("ELEMENTSPEC._addModel ",e);const t=this.shadowRoot.getElementById("addModel"),o={behaviour:"inline",css:"",predicate:"",desc:"",type:t.selected,output:"",template:"",sourcerend:!1,models:[],parameters:[],renditions:[],show:!0},i=Array.from(this.models);i.unshift(o),this.models=i,this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}})),t.selected="",this.requestUpdate()}_remove(e){this.dispatchEvent(new CustomEvent("element-spec-removed",{composed:!0,bubbles:!0,detail:{target:this}}))}_paste(e){console.log("_paste ",e),this.dispatchEvent(new CustomEvent("odd-paste",{composed:!0,bubbles:!0,detail:{target:this}}))}setCurrentSelection(e,t){e.preventDefault(),e.stopPropagation(),this._setCurrentSelection(t,e.target)}_setCurrentSelection(e,t){const o=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[e];o&&(o.hasAttribute("currentselection")||(this.dispatchEvent(new CustomEvent("current-changed",{composed:!0,bubbles:!0,detail:{target:t}})),this.requestUpdate()))}_removeModel(e){console.log("_removeModel ",e),e.stopPropagation();const{model:t}=e.target,o=this.models.indexOf(t);this.shadowRoot.getElementById("dialog").confirm(l("odd.editor.model.delete-model-label"),l("odd.editor.model.delete-model-message")).then(()=>{const e=Array.from(this.models);e.splice(o,1),this.models=e,this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}}))},()=>null)}_moveModelDown(e){console.log("ELEMENTSPEC._moveModelDown ",e),e.stopPropagation();const{model:t}=e.target,o=this.models.indexOf(t);if(o===this.models.length)return;const i=Array.from(this.models);i.splice(o,1),i.splice(o+1,0,t),this.models=i;const s=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o+1];s&&(this._setCurrentSelection(o+1,s),this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}})))}_moveModelUp(e){e.stopPropagation();const{model:t}=e.target,o=this.models.indexOf(t);if(0===o)return;const i=Array.from(this.models);i.splice(o,1),i.splice(o-1,0,t),this.models=i;const s=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o-1];this._setCurrentSelection(o-1,s),this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}}))}handleModelChanged(e){e.stopPropagation();const t=this.models.indexOf(e.detail.oldModel),o=Array.from(this.models);o.splice(t,1,e.detail.newModel),this.models=o,this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}})),this.requestUpdate()}}customElements.define("pb-odd-elementspec-editor",H);class K extends(m(E(y))){static get styles(){return _`
|
|
1133
|
+
`}addModel(e){this.models.unshift(e),this.requestUpdate()}_addModel(e){console.log("ELEMENTSPEC._addModel ",e);const t=this.shadowRoot.getElementById("addModel"),o={behaviour:"inline",css:"",mode:"",predicate:"",desc:"",type:t.selected,output:"",template:"",sourcerend:!1,models:[],parameters:[],renditions:[],show:!0},i=Array.from(this.models);i.unshift(o),this.models=i,this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}})),t.selected="",this.requestUpdate()}_remove(e){this.dispatchEvent(new CustomEvent("element-spec-removed",{composed:!0,bubbles:!0,detail:{target:this}}))}_paste(e){console.log("_paste ",e),this.dispatchEvent(new CustomEvent("odd-paste",{composed:!0,bubbles:!0,detail:{target:this}}))}setCurrentSelection(e,t){e.preventDefault(),e.stopPropagation(),this._setCurrentSelection(t,e.target)}_setCurrentSelection(e,t){const o=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[e];o&&(o.hasAttribute("currentselection")||(this.dispatchEvent(new CustomEvent("current-changed",{composed:!0,bubbles:!0,detail:{target:t}})),this.requestUpdate()))}_removeModel(e){console.log("_removeModel ",e),e.stopPropagation();const{model:t}=e.target,o=this.models.indexOf(t);this.shadowRoot.getElementById("dialog").confirm(l("odd.editor.model.delete-model-label"),l("odd.editor.model.delete-model-message")).then(()=>{const e=Array.from(this.models);e.splice(o,1),this.models=e,this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}}))},()=>null)}_moveModelDown(e){console.log("ELEMENTSPEC._moveModelDown ",e),e.stopPropagation();const{model:t}=e.target,o=this.models.indexOf(t);if(o===this.models.length)return;const i=Array.from(this.models);i.splice(o,1),i.splice(o+1,0,t),this.models=i;const s=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o+1];s&&(this._setCurrentSelection(o+1,s),this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}})))}_moveModelUp(e){e.stopPropagation();const{model:t}=e.target,o=this.models.indexOf(t);if(0===o)return;const i=Array.from(this.models);i.splice(o,1),i.splice(o-1,0,t),this.models=i;const s=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o-1];this._setCurrentSelection(o-1,s),this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}}))}handleModelChanged(e){e.stopPropagation();const t=this.models.indexOf(e.detail.oldModel),o=Array.from(this.models);o.splice(t,1,e.detail.newModel),this.models=o,this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}})),this.requestUpdate()}}customElements.define("pb-odd-elementspec-editor",H);class K extends(m(E(y))){static get styles(){return _`
|
|
1125
1134
|
:host {
|
|
1126
1135
|
display: flex;
|
|
1127
1136
|
/*margin: 30px 20px;*/
|
|
@@ -1316,7 +1325,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
1316
1325
|
<paper-input id="titleShort" name="short-title" .value="${this.titleShort}" label="${d("odd.editor.title-short")}"
|
|
1317
1326
|
placeholder="[${d("odd.editor.title-short-placeholder")}]"
|
|
1318
1327
|
@change="${e=>this.titleShort=e.composedPath()[0].value}"></paper-input>
|
|
1319
|
-
<paper-input id="description" name="description" .value="${
|
|
1328
|
+
<paper-input id="description" name="description" .value="${T(this.description)}" label="${d("odd.editor.description-label")}"
|
|
1320
1329
|
placeholder="[${d("odd.editor.description-placeholder")}]"
|
|
1321
1330
|
@change="${e=>this.description=e.composedPath()[0].value}"></paper-input>
|
|
1322
1331
|
<paper-input id="source" name="source" ?value="${this.source}" label="${d("odd.editor.source-label")}"
|
|
@@ -1354,4 +1363,4 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
1354
1363
|
|
|
1355
1364
|
<pb-message id="dialog" hidden></pb-message>
|
|
1356
1365
|
<pb-message id="errorMsg"></pb-message>
|
|
1357
|
-
`}firstUpdated(e){this.shadowRoot.getElementById("useNamespace").checked=this.useNamespace,this.jumpCtrl=this.shadowRoot.getElementById("jumpTo"),this.jumpCtrl.addEventListener("autocomplete-selected",this.jumpTo.bind(this));const t=this.querySelector("odd-selector");this.odd&&t&&(t.selected=this.odd,t.addEventListener("odd-selected",e=>{confirm("Any unsaved changes will be lost. Continue?")&&(this.odd=e.detail.odd,window.history.pushState({},"","?odd="+this.odd)),t.selected=this.odd})),this.addEventListener("current-changed",this._changeSelection),this.addEventListener("odd-copy",e=>this._copy(e)),this.addEventListener("odd-paste",e=>this._paste(e)),this.addEventListener("element-spec-removed",this.removeElementSpec.bind(this)),window.addEventListener("beforeunload",()=>"Any unsaved changes will be lost. Continue?"),this.subscribeTo("pb-login",e=>{this.loggedIn=null!=e.detail.user}),this.focus(),this.loadContent=this.shadowRoot.getElementById("loadContent"),this.rootPath=this.getAttribute("root-path"),K.waitOnce("pb-page-ready",()=>{this.load(),this.inited=!0}),this.registerHotkey("save",this.save.bind(this))}setUseNamespace(){this.useNamespace=this.shadowRoot.getElementById("useNamespace").checked}async load(){if(this.loading)return;if(this.loading=!0,""===this.rootPath||""===this.odd)return;this.elementSpecs=[],document.dispatchEvent(new CustomEvent("pb-start-update"));this.shadowRoot.getElementById("editSource").setPath(this.rootPath+"/"+this.odd);const e={odd:this.odd,root:this.rootPath};this.loadContent.params=e,this.loadContent.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`;this.loadContent.generateRequest().completes.then(e=>this.handleOdd(e))}handleOdd(e){const t=e.response;if(this.loggedIn=t.canWrite,this.source=t.source,this.title=t.title,this.titleShort=t.titleShort,this.description=t.description,this.cssFile=null==t.cssFile?"":t.cssFile,this.namespace=null!=t.namespace?t.namespace:"",this.useNamespace=null!=t.namespace,this.cssFile){this.shadowRoot.getElementById("editCSS").setPath(this.rootPath+"/"+this.cssFile)}this.elementSpecs=t.elementSpecs.map(e=>this.mapElementSpec(e)),this._updateAutoComplete(),this.requestUpdate(),this.loading=!1,document.dispatchEvent(new CustomEvent("pb-end-update")),document.title=this.titleShort||this.title}_updateAutoComplete(){this.shadowRoot.getElementById("jumpTo").source=this.elementSpecs.map(this._specMapper)}_cssFileChanged(e){if(this.cssFile=e.composedPath()[0].value,this.cssFile){this.shadowRoot.getElementById("editCSS").setPath(this.rootPath+"/"+this.cssFile)}}_navlistActiveChanged(e,t){this.selectedNavIndex=t,this.requestUpdate()}_returnTabs(){return this.tabs}_selectTab(e,t){const o=this.elementSpecs.find(e=>e.ident===t);this._updateElementspec(o)}_openElementSpec(e,t){console.log("_openElementSpec ",e,t);const o=this.elementSpecs[t];this._updateElementspec(o);const i=o.ident;if(this.tabs.indexOf(i)>=0)return this.tabIndex=this.tabs.indexOf(i),void this.requestUpdate();this.tabs.push(i),this.tabIndex=this.tabs.length-1,this.requestUpdate()}_updateElementspec(e){const t=this.shadowRoot.getElementById("currentElement");t.innerHTML="";const o=new H;o.addEventListener("element-spec-changed",this.handleElementSpecChanged.bind(this)),o.ident=e.ident,o.models=e.models,o.mode=e.mode,o.endpoint=this._endpoint,o.apiVersion=this._apiVersion,o.hotkeys=this.hotkeys,t.appendChild(o)}_closeTabHandler(e,t){return console.log("_closeTabHandler ",t),e.preventDefault(),e.stopPropagation(),this._closeTab(t),!1}_closeTab(e){if(this.tabs.splice(e,1),0===this.tabs.length)this.shadowRoot.getElementById("currentElement").innerHTML="",this.tabIndex=0,this.tabs=[];else if(this.tabIndex>0&&this.tabIndex>=e){this.tabIndex-=1;const e=this.tabs[this.tabIndex];this._selectTab(null,e)}}attributeChangedCallback(e,t,o){super.attributeChangedCallback(e,t,o),"odd"==e&&t!==o&&this.inited&&this.load()}static get replaceCharMap(){return{'"':""","&":"&","<":"<",">":">"}}static get replaceCharRegexp(){return/"|&|<|>/g}static replaceChars(e){return K.replaceCharMap[e]}jumpTo(e){const t="#es_"+this.shadowRoot.getElementById("jumpTo").text,o=this.shadowRoot.querySelector(t);o&&(this.jumpCtrl.clear(),o.click())}_computedTitle(){return this.odd?this.title||this.titleShort||this.odd||"Loading ...":""}_copy(e){this.clipboard=e.detail.model;const t=JSON.parse(JSON.stringify(e.detail.model));this.clipboard=t}_paste(e){if(console.log("_paste ",e),console.log("_paste clipboard",this.clipboard),this.clipboard=={}||null==this.clipboard)return;const t=e.detail.target;t.addModel(this.clipboard),t.render()}_specMapper(e){return{text:e.ident,value:e.ident}}_specObserver(e){const t=this.elementSpecs.map(this._specMapper);this.jumpCtrl.source=t}mapElementSpec(e){return Object.assign({},e,{models:e.models.map(e=>this.addShowToModel(e))})}addShowToModel(e){if(e.models){const t=e.models.map(e=>this.addShowToModel(e));return Object.assign({},e,{models:t,show:!1})}return Object.assign({},e,{show:!1})}addElementSpec(e){const t=this.shadowRoot.getElementById("identNew").value;if(!t||0===t.length)return;if(this.elementSpecs.find(e=>e.ident===t)){console.log("<pb-odd-editor> element spec to be added already exists: %s",t);const e="#es_"+t,o=this.shadowRoot.querySelector(e);if(!o)return;return void o.click()}const o={action:"find",odd:this.odd,root:this.rootPath,ident:t},i={root:this.rootPath,ident:t},s=this.lessThanApiVersion("1.0.0")?o:i;this.loadContent.params=s,this.loadContent.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`,this.loadContent.generateRequest().completes.then(this._handleElementSpecResponse.bind(this))}_handleElementSpecResponse(e){const t=this.shadowRoot.getElementById("identNew"),o=e.response,i=t.value,s={ident:i,mode:"not-found"===o.status?"add":"change",models:o.models||[]};this.elementSpecs.unshift(s),t.value="",this.tabs.push(i),this.tabIndex=this.tabs.length-1,this.elementSpecs.sort((e,t)=>e.ident.localeCompare(t.ident)),this.requestUpdate().then(()=>{const e=this.shadowRoot.querySelectorAll("paper-item"),t=this.elementSpecs.indexOf(s);this._updateAutoComplete(),e[t].click(),e[t].focus()})}removeElementSpec(e){const t=e.detail.target.ident;this.shadowRoot.getElementById("dialog").confirm(l("browse.delete"),l("odd.editor.delete-spec",{ident:t})).then(()=>{const e=this.elementSpecs.findIndex(e=>e.ident===t);this.elementSpecs.splice(e,1),this.requestUpdate();const o=this.shadowRoot.querySelector("vaadin-tab[selected]").getAttribute("name"),i=this.tabs.indexOf(o);this._closeTab(i)},()=>null)}serializeOdd(){const e=this.useNamespace?` ns="${this.namespace}"`:"",t=this.source?` source="${this.source}"`:"",o=this.description?` <desc>${this.description}</desc>`:"";return`<schemaSpec xmlns="http://www.tei-c.org/ns/1.0" xmlns:pb="http://teipublisher.com/1.0"${e}${t}>\n${`${this.indentString}<title>${this.title}${o}</title>\n`}${this.titleShort?`${this.indentString}<title type="short">${this.titleShort}</title>\n`:""}${this.cssFile?`${this.indentString}<rendition source="${this.cssFile}"/>\n`:""}\n${this.elementSpecs.map(e=>this.serializeElementSpec(this.indentString,e)).join("")}</schemaSpec>\n`}serializeElementSpec(e,t){const o=t.mode?` mode="${t.mode}"`:"",i=e+this.indentString,s=t.models.map(e=>this.serializeModel(i,e)).join("");return`${e}<elementSpec ident="${t.ident}"${o}>\n${s}${e}</elementSpec>\n`}serializeModel(e,t){if("model"===t.type&&!t.behaviour)return"";const o=e+this.indentString,i=[this.serializeAttribute("output",t.output),this.serializeAttribute("predicate",t.predicate),"model"===t.type?this.serializeAttribute("behaviour",t.behaviour):"",this.serializeAttribute("cssClass",t.css),this.serializeAttribute("useSourceRendition",t.sourcerend)].join(""),s=t.desc?o+"<desc>"+t.desc+"</desc>\n":"",r=t.models.map(e=>this.serializeModel(o,e)).join(""),a=t.parameters.map(e=>this.serializeParameter(o,e)).join(""),n=t.renditions.map(e=>this.serializeRendition(o,e)).join(""),d=`${s}${r}${a}${K.serializeTemplate(o,t.template)}${n}`,l=d.length>0?`>\n${d}${e}</${t.type}`:"/";return`${e}<${t.type}${i}${l}>\n`}serializeParameter(e,t){if(!t.name)return"";return`${e}<param${this.serializeAttribute("name",t.name)}${this.serializeAttribute("value",t.value)}/>\n`}serializeRendition(e,t){return`${e}<outputRendition xml:space="preserve" ${t.scope&&"null"!==t.scope?this.serializeAttribute("scope",t.scope):""}>\n${e}${K.escape(t.css)}\n${e}</outputRendition>\n`}static serializeTemplate(e,t){return t?`${e}<pb:template xml:space="preserve" xmlns="">${t}</pb:template>\n`:""}serializeAttribute(e,t){return t?` ${e}="${K.escape(t)}"`:""}static escape(e){return e?"string"==typeof e?e.replace(K.replaceCharRegexp,K.replaceChars):e:""}save(e){document.dispatchEvent(new CustomEvent("pb-start-update"));const t=this.serializeOdd();console.log("serialised ODD:",t),this.shadowRoot.getElementById("dialog").show(l("odd.editor.save"),l("odd.editor.saving"));const o=this.shadowRoot.getElementById("saveOdd");o.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`,this.lessThanApiVersion("1.0.0")?(o.contentType="application/x-www-form-urlencoded",o.method="POST",o.params=null,o.body={action:"save",root:this.rootPath,"output-prefix":this.outputPrefix,"output-root":this.outputRoot,odd:this.odd,data:t}):(o.contentType="application/xml",o.method="PUT",o.params={root:this.rootPath,"output-prefix":this.outputPrefix,"output-root":this.outputRoot},o.body=t);o.generateRequest().completes.then(this.handleSaveComplete.bind(this)).catch(this.handleSaveError.bind(this))}static _renderReport(e){return e.error?`\n <div class="list-group-item-danger">\n <h4 class="list-group-item-heading">${e.file}</h4>\n <h5 class="list-group-item-heading">Compilation error on line ${e.line}:</h5>\n <pre class="list-group-item-text">${e.error}</pre>\n <pre class="list-group-item-text">${e.message}</pre>\n </div>\n `:`\n <div class="list-group-item-success">\n <p class="list-group-item-text">Generated ${e.file}</p>\n </div>\n `}handleSaveComplete(e){const t=e.response;if("denied"===t.status)return this.shadowRoot.getElementById("dialog").set(l("odd.editor.denied"),l("odd.editor.denied-message",{odd:this.odd})),void document.dispatchEvent(new CustomEvent("pb-end-update"));let o;if(this.lessThanApiVersion("1.0.0")){o=`<div class="list-group">${t.report.map(K._renderReport).join("")}</div>`}else{o=`<div class="list-group">${t.report}</div>`}this.shadowRoot.getElementById("dialog").set(l("odd.editor.saved"),o),document.dispatchEvent(new CustomEvent("pb-end-update"))}handleSaveError(e){this.shadowRoot.getElementById("dialog").set("Error",e.error),document.dispatchEvent(new CustomEvent("pb-end-update"))}_reload(){this.shadowRoot.getElementById("dialog").confirm(l("odd.editor.reload"),l("odd.editor.reload-confirm")).then(()=>{this.load(),this.tabs=[],this.tabIndex=0,this.shadowRoot.getElementById("currentElement").innerHTML=""},()=>null)}_setCurrentSelection(e){null!=this.currentSelection&&this.currentSelection.removeAttribute("currentselection"),this.currentSelection=e.target,this.currentSelection.setAttribute("currentselection","true")}_changeSelection(e){if(e.preventDefault(),e.stopPropagation(),e.detail.target===this)return;let t;this.currentSelection&&void 0!==this.currentSelection.tagName&&this.currentSelection.removeAttribute("currentselection"),t=e.detail.target?e.detail.target:e.target,t.setAttribute("currentselection","true"),this.currentSelection=t}_selectElementspec(e){this.currentElementSpec&&"PB-ODD-ELEMENTSPEC-EDITOR"===this.currentElementSpec.tagName&&this.currentElementSpec.removeAttribute("currentselection");const t=e.target;t.setAttribute("currentselection","true"),this.currentElementSpec=t}nsDisabled(){return!this.useNamespace}_handleLoadError(e){console.log("loading error occurred: ",e);const t=this.shadowRoot.getElementById("errorMsg");t.style.background="red";const o=this.shadowRoot.getElementById("loadContent").url;console.log("url ",o),t.show("Error: ","ODD file could not be loaded from "+o)}handleElementSpecChanged(e){const t=this.elementSpecs.find(t=>t.ident===e.detail.ident),o=this.elementSpecs.indexOf(t),i=Object.assign({},t,{models:e.detail.models}),s=Array.from(this.elementSpecs);s.splice(o,1,i),this.elementSpecs=s}_inputTitle(e){this.title=e.composedPath()[0].value}}customElements.define("pb-odd-editor",K);export{K as PbOddEditor};
|
|
1366
|
+
`}firstUpdated(e){this.shadowRoot.getElementById("useNamespace").checked=this.useNamespace,this.jumpCtrl=this.shadowRoot.getElementById("jumpTo"),this.jumpCtrl.addEventListener("autocomplete-selected",this.jumpTo.bind(this));const t=this.querySelector("odd-selector");this.odd&&t&&(t.selected=this.odd,t.addEventListener("odd-selected",e=>{confirm("Any unsaved changes will be lost. Continue?")&&(this.odd=e.detail.odd,window.history.pushState({},"","?odd="+this.odd)),t.selected=this.odd})),this.addEventListener("current-changed",this._changeSelection),this.addEventListener("odd-copy",e=>this._copy(e)),this.addEventListener("odd-paste",e=>this._paste(e)),this.addEventListener("element-spec-removed",this.removeElementSpec.bind(this)),window.addEventListener("beforeunload",()=>"Any unsaved changes will be lost. Continue?"),this.subscribeTo("pb-login",e=>{this.loggedIn=null!=e.detail.user}),this.focus(),this.loadContent=this.shadowRoot.getElementById("loadContent"),this.rootPath=this.getAttribute("root-path"),K.waitOnce("pb-page-ready",()=>{this.load(),this.inited=!0}),this.registerHotkey("save",this.save.bind(this))}setUseNamespace(){this.useNamespace=this.shadowRoot.getElementById("useNamespace").checked}async load(){if(this.loading)return;if(this.loading=!0,""===this.rootPath||""===this.odd)return;this.elementSpecs=[],document.dispatchEvent(new CustomEvent("pb-start-update"));this.shadowRoot.getElementById("editSource").setPath(this.rootPath+"/"+this.odd);const e={odd:this.odd,root:this.rootPath};this.loadContent.params=e,this.loadContent.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`;this.loadContent.generateRequest().completes.then(e=>this.handleOdd(e))}handleOdd(e){const t=e.response;if(this.loggedIn=t.canWrite,this.source=t.source,this.title=t.title,this.titleShort=t.titleShort,this.description=t.description,this.cssFile=null==t.cssFile?"":t.cssFile,this.namespace=null!=t.namespace?t.namespace:"",this.useNamespace=null!=t.namespace,this.cssFile){this.shadowRoot.getElementById("editCSS").setPath(this.rootPath+"/"+this.cssFile)}this.elementSpecs=t.elementSpecs.map(e=>this.mapElementSpec(e)),this._updateAutoComplete(),this.requestUpdate(),this.loading=!1,document.dispatchEvent(new CustomEvent("pb-end-update")),document.title=this.titleShort||this.title}_updateAutoComplete(){this.shadowRoot.getElementById("jumpTo").source=this.elementSpecs.map(this._specMapper)}_cssFileChanged(e){if(this.cssFile=e.composedPath()[0].value,this.cssFile){this.shadowRoot.getElementById("editCSS").setPath(this.rootPath+"/"+this.cssFile)}}_navlistActiveChanged(e,t){this.selectedNavIndex=t,this.requestUpdate()}_returnTabs(){return this.tabs}_selectTab(e,t){const o=this.elementSpecs.find(e=>e.ident===t);this._updateElementspec(o)}_openElementSpec(e,t){console.log("_openElementSpec ",e,t);const o=this.elementSpecs[t];this._updateElementspec(o);const i=o.ident;if(this.tabs.indexOf(i)>=0)return this.tabIndex=this.tabs.indexOf(i),void this.requestUpdate();this.tabs.push(i),this.tabIndex=this.tabs.length-1,this.requestUpdate()}_updateElementspec(e){const t=this.shadowRoot.getElementById("currentElement");t.innerHTML="";const o=new H;o.addEventListener("element-spec-changed",this.handleElementSpecChanged.bind(this)),o.ident=e.ident,o.models=e.models,o.mode=e.mode,o.endpoint=this._endpoint,o.apiVersion=this._apiVersion,o.hotkeys=this.hotkeys,t.appendChild(o)}_closeTabHandler(e,t){return console.log("_closeTabHandler ",t),e.preventDefault(),e.stopPropagation(),this._closeTab(t),!1}_closeTab(e){if(this.tabs.splice(e,1),0===this.tabs.length)this.shadowRoot.getElementById("currentElement").innerHTML="",this.tabIndex=0,this.tabs=[];else if(this.tabIndex>0&&this.tabIndex>=e){this.tabIndex-=1;const e=this.tabs[this.tabIndex];this._selectTab(null,e)}}attributeChangedCallback(e,t,o){super.attributeChangedCallback(e,t,o),"odd"==e&&t!==o&&this.inited&&this.load()}static get replaceCharMap(){return{'"':""","&":"&","<":"<",">":">"}}static get replaceCharRegexp(){return/"|&|<|>/g}static replaceChars(e){return K.replaceCharMap[e]}jumpTo(e){const t="#es_"+this.shadowRoot.getElementById("jumpTo").text,o=this.shadowRoot.querySelector(t);o&&(this.jumpCtrl.clear(),o.click())}_computedTitle(){return this.odd?this.title||this.titleShort||this.odd||"Loading ...":""}_copy(e){this.clipboard=e.detail.model;const t=JSON.parse(JSON.stringify(e.detail.model));this.clipboard=t}_paste(e){if(console.log("_paste ",e),console.log("_paste clipboard",this.clipboard),this.clipboard=={}||null==this.clipboard)return;const t=e.detail.target;t.addModel(this.clipboard),t.render()}_specMapper(e){return{text:e.ident,value:e.ident}}_specObserver(e){const t=this.elementSpecs.map(this._specMapper);this.jumpCtrl.source=t}mapElementSpec(e){return Object.assign({},e,{models:e.models.map(e=>this.addShowToModel(e))})}addShowToModel(e){if(e.models){const t=e.models.map(e=>this.addShowToModel(e));return Object.assign({},e,{models:t,show:!1})}return Object.assign({},e,{show:!1})}addElementSpec(e){const t=this.shadowRoot.getElementById("identNew").value;if(!t||0===t.length)return;if(this.elementSpecs.find(e=>e.ident===t)){console.log("<pb-odd-editor> element spec to be added already exists: %s",t);const e="#es_"+t,o=this.shadowRoot.querySelector(e);if(!o)return;return void o.click()}const o={action:"find",odd:this.odd,root:this.rootPath,ident:t},i={root:this.rootPath,ident:t},s=this.lessThanApiVersion("1.0.0")?o:i;this.loadContent.params=s,this.loadContent.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`,this.loadContent.generateRequest().completes.then(this._handleElementSpecResponse.bind(this))}_handleElementSpecResponse(e){const t=this.shadowRoot.getElementById("identNew"),o=e.response,i=t.value,s={ident:i,mode:"not-found"===o.status?"add":"change",models:o.models||[]};this.elementSpecs.unshift(s),t.value="",this.tabs.push(i),this.tabIndex=this.tabs.length-1,this.elementSpecs.sort((e,t)=>e.ident.localeCompare(t.ident)),this.requestUpdate().then(()=>{const e=this.shadowRoot.querySelectorAll("paper-item"),t=this.elementSpecs.indexOf(s);this._updateAutoComplete(),e[t].click(),e[t].focus()})}removeElementSpec(e){const t=e.detail.target.ident;this.shadowRoot.getElementById("dialog").confirm(l("browse.delete"),l("odd.editor.delete-spec",{ident:t})).then(()=>{const e=this.elementSpecs.findIndex(e=>e.ident===t);this.elementSpecs.splice(e,1),this.requestUpdate();const o=this.shadowRoot.querySelector("vaadin-tab[selected]").getAttribute("name"),i=this.tabs.indexOf(o);this._closeTab(i)},()=>null)}serializeOdd(){const e=this.useNamespace?` ns="${this.namespace}"`:"",t=this.source?` source="${this.source}"`:"",o=this.description?` <desc>${this.description}</desc>`:"";return`<schemaSpec xmlns="http://www.tei-c.org/ns/1.0" xmlns:pb="http://teipublisher.com/1.0"${e}${t}>\n${`${this.indentString}<title>${this.title}${o}</title>\n`}${this.titleShort?`${this.indentString}<title type="short">${this.titleShort}</title>\n`:""}${this.cssFile?`${this.indentString}<rendition source="${this.cssFile}"/>\n`:""}\n${this.elementSpecs.map(e=>this.serializeElementSpec(this.indentString,e)).join("")}</schemaSpec>\n`}serializeElementSpec(e,t){const o=t.mode?` mode="${t.mode}"`:"",i=e+this.indentString,s=t.models.map(e=>this.serializeModel(i,e)).join("");return`${e}<elementSpec ident="${t.ident}"${o}>\n${s}${e}</elementSpec>\n`}serializeModel(e,t){if("model"===t.type&&!t.behaviour)return"";const o=e+this.indentString,i=[this.serializeAttribute("output",t.output),this.serializeAttribute("predicate",t.predicate),"model"===t.type?this.serializeAttribute("behaviour",t.behaviour):"",this.serializeAttribute("cssClass",t.css),this.serializeAttribute("useSourceRendition",t.sourcerend),this.serializeAttribute("pb:mode",t.mode)].join(""),s=t.desc?o+"<desc>"+t.desc+"</desc>\n":"",r=t.models.map(e=>this.serializeModel(o,e)).join(""),a=t.parameters.map(e=>this.serializeParameter(o,e)).join(""),n=t.renditions.map(e=>this.serializeRendition(o,e)).join(""),d=`${s}${r}${a}${K.serializeTemplate(o,t.template)}${n}`,l=d.length>0?`>\n${d}${e}</${t.type}`:"/";return`${e}<${t.type}${i}${l}>\n`}serializeParameter(e,t){if(!t.name)return"";const o=this.serializeAttribute("name",t.name),i=this.serializeAttribute("value",t.value);return t.set?`${e}<pb:set-param xmlns=""${o}${i}/>\n`:`${e}<param${o}${i}/>\n`}serializeRendition(e,t){return`${e}<outputRendition xml:space="preserve" ${t.scope&&"null"!==t.scope?this.serializeAttribute("scope",t.scope):""}>\n${e}${K.escape(t.css)}\n${e}</outputRendition>\n`}static serializeTemplate(e,t){return t?`${e}<pb:template xml:space="preserve" xmlns="">${t}</pb:template>\n`:""}serializeAttribute(e,t){return t?` ${e}="${K.escape(t)}"`:""}static escape(e){return e?"string"==typeof e?e.replace(K.replaceCharRegexp,K.replaceChars):e:""}save(e){document.dispatchEvent(new CustomEvent("pb-start-update"));const t=this.serializeOdd();console.log("serialised ODD:",t),this.shadowRoot.getElementById("dialog").show(l("odd.editor.save"),l("odd.editor.saving"));const o=this.shadowRoot.getElementById("saveOdd");o.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`,this.lessThanApiVersion("1.0.0")?(o.contentType="application/x-www-form-urlencoded",o.method="POST",o.params=null,o.body={action:"save",root:this.rootPath,"output-prefix":this.outputPrefix,"output-root":this.outputRoot,odd:this.odd,data:t}):(o.contentType="application/xml",o.method="PUT",o.params={root:this.rootPath,"output-prefix":this.outputPrefix,"output-root":this.outputRoot},o.body=t);o.generateRequest().completes.then(this.handleSaveComplete.bind(this)).catch(this.handleSaveError.bind(this))}static _renderReport(e){return e.error?`\n <div class="list-group-item-danger">\n <h4 class="list-group-item-heading">${e.file}</h4>\n <h5 class="list-group-item-heading">Compilation error on line ${e.line}:</h5>\n <pre class="list-group-item-text">${e.error}</pre>\n <pre class="list-group-item-text">${e.message}</pre>\n </div>\n `:`\n <div class="list-group-item-success">\n <p class="list-group-item-text">Generated ${e.file}</p>\n </div>\n `}handleSaveComplete(e){const t=e.response;if("denied"===t.status)return this.shadowRoot.getElementById("dialog").set(l("odd.editor.denied"),l("odd.editor.denied-message",{odd:this.odd})),void document.dispatchEvent(new CustomEvent("pb-end-update"));let o;if(this.lessThanApiVersion("1.0.0")){o=`<div class="list-group">${t.report.map(K._renderReport).join("")}</div>`}else{o=`<div class="list-group">${t.report}</div>`}this.shadowRoot.getElementById("dialog").set(l("odd.editor.saved"),o),document.dispatchEvent(new CustomEvent("pb-end-update"))}handleSaveError(e){this.shadowRoot.getElementById("dialog").set("Error",e.error),document.dispatchEvent(new CustomEvent("pb-end-update"))}_reload(){this.shadowRoot.getElementById("dialog").confirm(l("odd.editor.reload"),l("odd.editor.reload-confirm")).then(()=>{this.load(),this.tabs=[],this.tabIndex=0,this.shadowRoot.getElementById("currentElement").innerHTML=""},()=>null)}_setCurrentSelection(e){null!=this.currentSelection&&this.currentSelection.removeAttribute("currentselection"),this.currentSelection=e.target,this.currentSelection.setAttribute("currentselection","true")}_changeSelection(e){if(e.preventDefault(),e.stopPropagation(),e.detail.target===this)return;let t;this.currentSelection&&void 0!==this.currentSelection.tagName&&this.currentSelection.removeAttribute("currentselection"),t=e.detail.target?e.detail.target:e.target,t.setAttribute("currentselection","true"),this.currentSelection=t}_selectElementspec(e){this.currentElementSpec&&"PB-ODD-ELEMENTSPEC-EDITOR"===this.currentElementSpec.tagName&&this.currentElementSpec.removeAttribute("currentselection");const t=e.target;t.setAttribute("currentselection","true"),this.currentElementSpec=t}nsDisabled(){return!this.useNamespace}_handleLoadError(e){console.log("loading error occurred: ",e);const t=this.shadowRoot.getElementById("errorMsg");t.style.background="red";const o=this.shadowRoot.getElementById("loadContent").url;console.log("url ",o),t.show("Error: ","ODD file could not be loaded from "+o)}handleElementSpecChanged(e){const t=this.elementSpecs.find(t=>t.ident===e.detail.ident),o=this.elementSpecs.indexOf(t),i=Object.assign({},t,{models:e.detail.models}),s=Array.from(this.elementSpecs);s.splice(o,1,i),this.elementSpecs=s}_inputTitle(e){this.title=e.composedPath()[0].value}}customElements.define("pb-odd-editor",K);export{K as PbOddEditor};
|
package/i18n/common/de.json
CHANGED
|
@@ -244,6 +244,13 @@
|
|
|
244
244
|
"modify": "Änderung am Text vornehmen",
|
|
245
245
|
"modify-info": "Achtung: dies ist keine Annotation. Die Änderung wird beim Merge auf den Transkriptionstext angewandt.",
|
|
246
246
|
"apply-all": "Alle selektieren und anwenden",
|
|
247
|
-
"permission": "Zugriff verweigert: keine Berechtigung zum Speichern von Annotationen."
|
|
247
|
+
"permission": "Zugriff verweigert: keine Berechtigung zum Speichern von Annotationen.",
|
|
248
|
+
"ner": {
|
|
249
|
+
"title": "Automatische Entitätenerkennung",
|
|
250
|
+
"description": "Erkannte Entitäten werden als Annotationen markiert.",
|
|
251
|
+
"run": "Ausführen",
|
|
252
|
+
"model": "Wähle ein Modell",
|
|
253
|
+
"denied": "Ungespeicherte Änderungen gefunden: bitte zuerst speichern oder verwerfen."
|
|
254
|
+
}
|
|
248
255
|
}
|
|
249
256
|
}
|
package/i18n/common/en.json
CHANGED
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"requiredGroup": "must be member of group {{group}}"
|
|
108
108
|
},
|
|
109
109
|
"search": {
|
|
110
|
-
"search":"Search",
|
|
110
|
+
"search": "Search",
|
|
111
111
|
"reset": "Reset",
|
|
112
112
|
"placeholder": "Enter Query",
|
|
113
113
|
"sections": "Search sections",
|
|
@@ -162,7 +162,8 @@
|
|
|
162
162
|
"custom-behaviour-placeholder": "[Custom Behaviour]",
|
|
163
163
|
"template-placeholder": "[Define code template to apply to content]",
|
|
164
164
|
"param-name-placeholder": "[Param name]",
|
|
165
|
-
"empty": "[Empty]"
|
|
165
|
+
"empty": "[Empty]",
|
|
166
|
+
"mode-placeholder": "Processing mode - passed to subsequent models"
|
|
166
167
|
},
|
|
167
168
|
"css-source": "Open CSS file"
|
|
168
169
|
}
|
|
@@ -244,6 +245,13 @@
|
|
|
244
245
|
"confirm-reload": "Discard current annotations and reload the source?",
|
|
245
246
|
"modify": "Apply an edit to the base text",
|
|
246
247
|
"modify-info": "Note: this is not an annotation, but will modify the base text when merged.",
|
|
247
|
-
"permission": "Permission denied: you are not allowed to save annotations."
|
|
248
|
+
"permission": "Permission denied: you are not allowed to save annotations.",
|
|
249
|
+
"ner": {
|
|
250
|
+
"title": "Named Entity Extraction",
|
|
251
|
+
"description": "Try to automatically find named entities in the text and mark them as annotations.",
|
|
252
|
+
"run": "Run",
|
|
253
|
+
"model": "Select a model",
|
|
254
|
+
"denied": "Unsaved changes found: please store or discard them first."
|
|
255
|
+
}
|
|
248
256
|
}
|
|
249
257
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teipublisher/pb-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.1",
|
|
4
4
|
"description": "Collection of webcomponents underlying TEI Publisher",
|
|
5
5
|
"repository": "https://github.com/eeditiones/tei-publisher-components.git",
|
|
6
6
|
"main": "index.html",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"@webcomponents/webcomponentsjs": "latest",
|
|
69
69
|
"animejs": "^3.2.0",
|
|
70
70
|
"codemirror": "^5.58.1",
|
|
71
|
+
"gridjs": "^5.0.2",
|
|
71
72
|
"hotkeys-js": "^3.8.1",
|
|
72
73
|
"i18next": "19.8.1",
|
|
73
74
|
"i18next-browser-languagedetector": "^6.0.1",
|