@teipublisher/pb-components 1.40.1 → 1.41.0
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 +20 -0
- package/dist/demo/pb-code-editor.html +12 -9
- package/dist/{iron-form-f540b15b.js → iron-form-9e72ac45.js} +1 -1
- package/dist/jinn-codemirror-c1a4b755.js +1 -0
- package/dist/{paper-checkbox-f6a70487.js → paper-checkbox-102e3b43.js} +120 -120
- package/dist/pb-code-editor.js +22 -0
- package/dist/pb-components-bundle.js +234 -234
- package/dist/pb-edit-app.js +33 -33
- package/dist/pb-elements.json +100 -16
- package/dist/pb-i18n-6ad23bcf.js +1 -0
- package/dist/pb-message-0fb0b538.js +911 -0
- package/dist/pb-odd-editor.js +110 -82
- package/package.json +4 -5
- package/pb-elements.json +100 -16
- package/src/pb-code-editor.js +51 -663
- package/src/pb-components.js +0 -1
- package/src/pb-load.js +11 -0
- package/src/pb-odd-model-editor.js +33 -23
- package/src/pb-odd-parameter-editor.js +17 -9
- package/src/pb-odd-rendition-editor.js +19 -9
- package/css/codemirror/3024-day.css +0 -41
- package/css/codemirror/3024-night.css +0 -39
- package/css/codemirror/abbott.css +0 -268
- package/css/codemirror/abcdef.css +0 -32
- package/css/codemirror/ambiance-mobile.css +0 -5
- package/css/codemirror/ambiance.css +0 -74
- package/css/codemirror/ayu-dark.css +0 -44
- package/css/codemirror/ayu-mirage.css +0 -45
- package/css/codemirror/base16-dark.css +0 -40
- package/css/codemirror/base16-light.css +0 -38
- package/css/codemirror/bespin.css +0 -34
- package/css/codemirror/blackboard.css +0 -32
- package/css/codemirror/cobalt.css +0 -25
- package/css/codemirror/colorforth.css +0 -33
- package/css/codemirror/darcula.css +0 -53
- package/css/codemirror/dracula.css +0 -40
- package/css/codemirror/duotone-dark.css +0 -35
- package/css/codemirror/duotone-light.css +0 -36
- package/css/codemirror/eclipse.css +0 -23
- package/css/codemirror/elegant.css +0 -13
- package/css/codemirror/erlang-dark.css +0 -34
- package/css/codemirror/gruvbox-dark.css +0 -39
- package/css/codemirror/hopscotch.css +0 -34
- package/css/codemirror/icecoder.css +0 -43
- package/css/codemirror/idea.css +0 -42
- package/css/codemirror/isotope.css +0 -34
- package/css/codemirror/juejin.css +0 -30
- package/css/codemirror/lesser-dark.css +0 -47
- package/css/codemirror/liquibyte.css +0 -95
- package/css/codemirror/lucario.css +0 -37
- package/css/codemirror/material-darker.css +0 -135
- package/css/codemirror/material-ocean.css +0 -141
- package/css/codemirror/material-palenight.css +0 -141
- package/css/codemirror/material.css +0 -141
- package/css/codemirror/mbo.css +0 -37
- package/css/codemirror/mdn-like.css +0 -46
- package/css/codemirror/midnight.css +0 -39
- package/css/codemirror/monokai.css +0 -41
- package/css/codemirror/moxer.css +0 -143
- package/css/codemirror/neat.css +0 -12
- package/css/codemirror/neo.css +0 -43
- package/css/codemirror/night.css +0 -27
- package/css/codemirror/nord.css +0 -42
- package/css/codemirror/oceanic-next.css +0 -46
- package/css/codemirror/panda-syntax.css +0 -85
- package/css/codemirror/paraiso-dark.css +0 -38
- package/css/codemirror/paraiso-light.css +0 -38
- package/css/codemirror/pastel-on-dark.css +0 -52
- package/css/codemirror/railscasts.css +0 -34
- package/css/codemirror/rubyblue.css +0 -25
- package/css/codemirror/seti.css +0 -44
- package/css/codemirror/shadowfox.css +0 -52
- package/css/codemirror/solarized.css +0 -168
- package/css/codemirror/ssms.css +0 -16
- package/css/codemirror/the-matrix.css +0 -30
- package/css/codemirror/tomorrow-night-bright.css +0 -35
- package/css/codemirror/tomorrow-night-eighties.css +0 -38
- package/css/codemirror/ttcn.css +0 -64
- package/css/codemirror/twilight.css +0 -32
- package/css/codemirror/vibrant-ink.css +0 -34
- package/css/codemirror/xq-dark.css +0 -53
- package/css/codemirror/xq-light.css +0 -43
- package/css/codemirror/yeti.css +0 -44
- package/css/codemirror/yonce.css +0 -59
- package/css/codemirror/zenburn.css +0 -37
- package/dist/pb-message-1a0c0c52.js +0 -1360
- package/lib/codemirror/addon/display/placeholder.js +0 -70
- package/lib/codemirror/addon/edit/matchbrackets.js +0 -152
- package/lib/codemirror/addon/lint/lint.js +0 -282
- package/lib/codemirror/mode/css/css.js +0 -855
- package/lib/codemirror/mode/stex/stex.js +0 -249
- package/lib/codemirror/mode/xml/xml.js +0 -404
- package/lib/codemirror/mode/xquery/xquery.js +0 -434
package/dist/pb-odd-editor.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as e,
|
|
1
|
+
import{h as e,m as t,F as o,D as i,z as s,A as r,j as a,f as n}from"./paper-checkbox-102e3b43.js";import{E as l,T as d,D as p,p as c}from"./pb-message-0fb0b538.js";import{d as h,N as m,e as u,f as b,j as g,A as v,L as f,c as w,h as y,a as _,p as x}from"./pb-mixin-15ff531f.js";import{t as $,g as E}from"./pb-i18n-6ad23bcf.js";import"./jinn-codemirror-c1a4b755.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
@@ -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(
|
|
15
|
+
const S=(e,t)=>{const o=e.startNode.parentNode,i=void 0===t?e.endNode:t.startNode,s=o.insertBefore(u(),i);o.insertBefore(u(),i);const r=new m(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&&b(i,t.startNode,r,s)},A=e=>{g(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,z=h((e,t,o)=>{let i;return void 0===o?o=t:void 0!==t&&(i=t),t=>{if(!(t instanceof m))throw new Error("repeat can only be used in text bindings");const s=R.get(t)||[],r=I.get(t)||[],a=[],n=[],l=[];let d,p,c=0;for(const t of e)l[c]=i?i(t,c):c,n[c]=o(t,c),c++;let h=0,u=s.length-1,b=0,g=n.length-1;for(;h<=u&&b<=g;)if(null===s[h])h++;else if(null===s[u])u--;else if(r[h]===l[b])a[b]=C(s[h],n[b]),h++,b++;else if(r[u]===l[g])a[g]=C(s[u],n[g]),u--,g--;else if(r[h]===l[g])a[g]=C(s[h],n[g]),k(t,s[h],a[g+1]),h++,g--;else if(r[u]===l[b])a[b]=C(s[u],n[b]),k(t,s[u],s[h]),u--,b++;else if(void 0===d&&(d=M(l,b,g),p=M(r,h,u)),d.has(r[h]))if(d.has(r[u])){const e=p.get(l[b]),o=void 0!==e?s[e]:null;if(null===o){const e=S(t,s[h]);C(e,n[b]),a[b]=e}else a[b]=C(o,n[b]),k(t,o,s[h]),s[e]=null;b++}else A(s[u]),u--;else A(s[h]),h++;for(;b<=g;){const e=S(t,a[g+1]);C(e,n[b]),a[b++]=e}for(;h<=u;){const e=s[h++];null!==e&&A(e)}R.set(t,a),I.set(t,l)}}),P=new WeakMap,B=h(e=>t=>{const o=P.get(t);if(void 0===e&&t instanceof v){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)}),T=e`<dom-module id="lumo-tab" theme-for="vaadin-tab">
|
|
16
16
|
<template>
|
|
17
17
|
<style>
|
|
18
18
|
:host {
|
|
@@ -245,9 +245,9 @@ const O=e=>class extends e{static get properties(){return{_hasVaadinItemMixin:{v
|
|
|
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
|
|
248
|
+
*/;class j extends(l(d(O(t)))){static get template(){return e`
|
|
249
249
|
<slot></slot>
|
|
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(
|
|
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(j.is,j);const q=e`<dom-module id="lumo-tabs" theme-for="vaadin-tabs">
|
|
251
251
|
<template>
|
|
252
252
|
<style>
|
|
253
253
|
:host {
|
|
@@ -477,18 +477,18 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
477
477
|
}
|
|
478
478
|
</style>
|
|
479
479
|
</template>
|
|
480
|
-
</dom-module>`;document.head.appendChild(
|
|
480
|
+
</dom-module>`;document.head.appendChild(q.content);
|
|
481
481
|
/**
|
|
482
482
|
@license
|
|
483
483
|
Copyright (c) 2017 Vaadin Ltd.
|
|
484
484
|
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
485
485
|
*/
|
|
486
|
-
const
|
|
486
|
+
const L=e=>class extends e{static get properties(){return{_hasVaadinListMixin:{value:!0},selected:{type:Number,reflectToAttribute:!0,notify:!0},orientation:{type:String,reflectToAttribute:!0,value:""},items:{type:Array,readOnly:!0,notify:!0},_searchBuf:{type:String,value:""}}}static get observers(){return["_enhanceItems(items, orientation, selected, disabled)"]}ready(){super.ready(),this.addEventListener("keydown",e=>this._onKeydown(e)),this.addEventListener("click",e=>this._onClick(e)),this._observer=new o(this,e=>{this._setItems(this._filterItems(Array.from(this.children)))})}_enhanceItems(e,t,o,i){if(!i&&e){this.setAttribute("aria-orientation",t||"vertical"),this.items.forEach(e=>{t?e.setAttribute("orientation",t):e.removeAttribute("orientation"),e.updateStyles()}),this._setFocusable(o);const i=e[o];e.forEach(e=>e.selected=e===i),i&&!i.disabled&&this._scrollToItem(o)}}get focused(){return this.getRootNode().activeElement}_filterItems(e){return e.filter(e=>e._hasVaadinItemMixin)}_onClick(e){if(e.metaKey||e.shiftKey||e.ctrlKey||e.defaultPrevented)return;const t=this._filterItems(e.composedPath())[0];let o;t&&!t.disabled&&(o=this.items.indexOf(t))>=0&&(this.selected=o)}_searchKey(e,t){this._searchReset=i.debounce(this._searchReset,s.after(500),()=>this._searchBuf=""),this._searchBuf+=t.toLowerCase();const o=1,r=e=>!(e.disabled||this._isItemHidden(e))&&0===e.textContent.replace(/[^a-zA-Z0-9]/g,"").toLowerCase().indexOf(this._searchBuf);this.items.some(e=>0===e.textContent.replace(/[^a-zA-Z0-9]/g,"").toLowerCase().indexOf(this._searchBuf))||(this._searchBuf=t.toLowerCase());const a=1===this._searchBuf.length?e+1:e;return this._getAvailableIndex(a,o,r)}get _isRTL(){return!this._vertical&&"rtl"===this.getAttribute("dir")}_onKeydown(e){if(e.metaKey||e.ctrlKey)return;const t=e.key.replace(/^Arrow/,""),o=this.items.indexOf(this.focused);if(/[a-zA-Z0-9]/.test(t)&&1===t.length){const e=this._searchKey(o,t);return void(e>=0&&this._focus(e))}const i=e=>!(e.disabled||this._isItemHidden(e));let s,r;const a=this._isRTL?-1:1;this._vertical&&"Up"===t||!this._vertical&&"Left"===t?(r=-a,s=o-a):this._vertical&&"Down"===t||!this._vertical&&"Right"===t?(r=a,s=o+a):"Home"===t?(r=1,s=0):"End"===t&&(r=-1,s=this.items.length-1),s=this._getAvailableIndex(s,r,i),s>=0&&(this._focus(s),e.preventDefault())}_getAvailableIndex(e,t,o){const i=this.items.length;for(let s=0;"number"==typeof e&&s<i;s++,e+=t||1){e<0?e=i-1:e>=i&&(e=0);if(o(this.items[e]))return e}return-1}_isItemHidden(e){return"none"===getComputedStyle(e).display}_setFocusable(e){e=this._getAvailableIndex(e,1,e=>!e.disabled);const t=this.items[e]||this.items[0];this.items.forEach(e=>e.tabIndex=e===t?0:-1)}_focus(e){const t=this.items[e];this.items.forEach(e=>e.focused=e===t),this._setFocusable(e),this._scrollToItem(e),t.focus()}focus(){this._observer&&this._observer.flush();const e=this.querySelector('[tabindex="0"]')||(this.items?this.items[0]:null);e&&e.focus()}get _scrollerElement(){}_scrollToItem(e){const t=this.items[e];if(!t)return;const o=this._vertical?["top","bottom"]:this._isRTL?["right","left"]:["left","right"],i=this._scrollerElement.getBoundingClientRect(),s=(this.items[e+1]||t).getBoundingClientRect(),r=(this.items[e-1]||t).getBoundingClientRect();let a=0;!this._isRTL&&s[o[1]]>=i[o[1]]||this._isRTL&&s[o[1]]<=i[o[1]]?a=s[o[1]]-i[o[1]]:(!this._isRTL&&r[o[0]]<=i[o[0]]||this._isRTL&&r[o[0]]>=i[o[0]])&&(a=r[o[0]]-i[o[0]]),this._scroll(a)}get _vertical(){return"horizontal"!==this.orientation}_scroll(e){if(this._vertical)this._scrollerElement.scrollTop+=e;else{const t=p.detectScrollType(),o=p.getNormalizedScrollLeft(t,this.getAttribute("dir")||"ltr",this._scrollerElement)+e;p.setNormalizedScrollLeft(t,this.getAttribute("dir")||"ltr",this._scrollerElement,o)}}}
|
|
487
487
|
/**
|
|
488
488
|
@license
|
|
489
489
|
Copyright (c) 2017 Vaadin Ltd.
|
|
490
490
|
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
491
|
-
*/,N=/Apple.* Version\/(9|10)/.test(navigator.userAgent);class D extends(
|
|
491
|
+
*/,N=/Apple.* Version\/(9|10)/.test(navigator.userAgent);class D extends(l(L(d(r([n],t))))){static get template(){return e`
|
|
492
492
|
<style>
|
|
493
493
|
:host {
|
|
494
494
|
display: flex;
|
|
@@ -574,7 +574,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
574
574
|
</div>
|
|
575
575
|
|
|
576
576
|
<div on-click="_scrollForward" part="forward-button"></div>
|
|
577
|
-
`}static get is(){return"vaadin-tabs"}static get version(){return"3.2.0"}static get properties(){return{orientation:{value:"horizontal",type:String},selected:{value:0,type:Number}}}static get observers(){return["_updateOverflow(items.*, vertical)"]}ready(){super.ready(),this.addEventListener("iron-resize",()=>this._updateOverflow()),this._scrollerElement.addEventListener("scroll",()=>this._updateOverflow()),this.setAttribute("role","tablist"),a(this,()=>{this._updateOverflow()})}_scrollForward(){this._scroll(-this.__direction*this._scrollOffset)}_scrollBack(){this._scroll(this.__direction*this._scrollOffset)}get _scrollOffset(){return this._vertical?this._scrollerElement.offsetHeight:this._scrollerElement.offsetWidth}get _scrollerElement(){return this.$.scroll}get __direction(){return this._vertical||"rtl"!==this.getAttribute("dir")?-1:1}_updateOverflow(){const e=this._vertical?this._scrollerElement.scrollTop:this.__getNormalizedScrollLeft(this._scrollerElement);let t=this._vertical?this._scrollerElement.scrollHeight:this._scrollerElement.scrollWidth;t-=1;let o=e>0?"start":"";o+=e+this._scrollOffset<t?" end":"",1==this.__direction&&(o=o.replace(/start|end/gi,e=>"start"===e?"end":"start")),o?this.setAttribute("overflow",o.trim()):this.removeAttribute("overflow"),this._repaintShadowNodesHack()}_repaintShadowNodesHack(){if(N&&this.root){const e="-webkit-backface-visibility";this.root.querySelectorAll("*").forEach(t=>{t.style[e]="visible",t.style[e]=""})}}}customElements.define(D.is,D);class
|
|
577
|
+
`}static get is(){return"vaadin-tabs"}static get version(){return"3.2.0"}static get properties(){return{orientation:{value:"horizontal",type:String},selected:{value:0,type:Number}}}static get observers(){return["_updateOverflow(items.*, vertical)"]}ready(){super.ready(),this.addEventListener("iron-resize",()=>this._updateOverflow()),this._scrollerElement.addEventListener("scroll",()=>this._updateOverflow()),this.setAttribute("role","tablist"),a(this,()=>{this._updateOverflow()})}_scrollForward(){this._scroll(-this.__direction*this._scrollOffset)}_scrollBack(){this._scroll(this.__direction*this._scrollOffset)}get _scrollOffset(){return this._vertical?this._scrollerElement.offsetHeight:this._scrollerElement.offsetWidth}get _scrollerElement(){return this.$.scroll}get __direction(){return this._vertical||"rtl"!==this.getAttribute("dir")?-1:1}_updateOverflow(){const e=this._vertical?this._scrollerElement.scrollTop:this.__getNormalizedScrollLeft(this._scrollerElement);let t=this._vertical?this._scrollerElement.scrollHeight:this._scrollerElement.scrollWidth;t-=1;let o=e>0?"start":"";o+=e+this._scrollOffset<t?" end":"",1==this.__direction&&(o=o.replace(/start|end/gi,e=>"start"===e?"end":"start")),o?this.setAttribute("overflow",o.trim()):this.removeAttribute("overflow"),this._repaintShadowNodesHack()}_repaintShadowNodesHack(){if(N&&this.root){const e="-webkit-backface-visibility";this.root.querySelectorAll("*").forEach(t=>{t.style[e]="visible",t.style[e]=""})}}}customElements.define(D.is,D);class U extends f{static get styles(){return w`
|
|
578
578
|
:host {
|
|
579
579
|
display: block;
|
|
580
580
|
}
|
|
@@ -586,28 +586,38 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
586
586
|
margin-bottom:10px;
|
|
587
587
|
}
|
|
588
588
|
|
|
589
|
+
.editor label {
|
|
590
|
+
margin-bottom:5px;
|
|
591
|
+
font-size: 12px;
|
|
592
|
+
font-weight: 400;
|
|
593
|
+
color: var(--paper-grey-500);
|
|
594
|
+
}
|
|
595
|
+
|
|
589
596
|
paper-dropdown-menu{
|
|
590
597
|
}
|
|
591
598
|
|
|
592
599
|
paper-icon-button{
|
|
593
600
|
align-self:center;
|
|
594
601
|
}
|
|
595
|
-
`}render(){return
|
|
602
|
+
`}render(){return y`
|
|
596
603
|
<div class="wrapper">
|
|
597
604
|
<paper-dropdown-menu label="Scope">
|
|
598
605
|
<paper-listbox id="scopeList" slot="dropdown-content" selected="${this.scope}" attr-for-selected="value"
|
|
599
606
|
@iron-select="${this._listchanged}">
|
|
600
|
-
${this.scopes.map(e=>
|
|
607
|
+
${this.scopes.map(e=>y`
|
|
601
608
|
<paper-item value="${e}">${e}</paper-item>
|
|
602
609
|
`)}
|
|
603
610
|
</paper-listbox>
|
|
604
611
|
</paper-dropdown-menu>
|
|
605
|
-
<
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
612
|
+
<div class="editor">
|
|
613
|
+
<label>Rendition</label>
|
|
614
|
+
<jinn-codemirror
|
|
615
|
+
id="editor"
|
|
616
|
+
label="Rendition"
|
|
617
|
+
code="${this.css}"
|
|
618
|
+
mode="css"
|
|
619
|
+
@update="${this._handleCodeChange}"></jinn-codemirror>
|
|
620
|
+
</div>
|
|
611
621
|
<paper-icon-button @click="${this._remove}" icon="delete" title="delete this rendition"></paper-icon-button>
|
|
612
622
|
</div>
|
|
613
623
|
|
|
@@ -615,7 +625,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
615
625
|
|
|
616
626
|
<slot></slot>
|
|
617
627
|
|
|
618
|
-
`}static get properties(){return{scopes:{type:Array},css:{type:String,reflect:!0},scope:{type:String,reflect:!0},selected:{type:String}}}constructor(){super(),this.scopes=["","before","after"],this.css="",this.scope="",this.selected="",this._initialized=!1}connectedCallback(){super.connectedCallback(),this.css=this.css.trim(),this.dispatchEvent(new CustomEvent("rendition-connected",{composed:!0,bubbles:!0,detail:{target:this}}))}firstUpdated(e){this.refreshEditor(),this._initialized=!0}refreshEditor(){console.log("refreshEditor");
|
|
628
|
+
`}static get properties(){return{scopes:{type:Array},css:{type:String,reflect:!0},scope:{type:String,reflect:!0},selected:{type:String}}}constructor(){super(),this.scopes=["","before","after"],this.css="",this.scope="",this.selected="",this._initialized=!1}connectedCallback(){super.connectedCallback(),this.css=this.css.trim(),this.dispatchEvent(new CustomEvent("rendition-connected",{composed:!0,bubbles:!0,detail:{target:this}}))}firstUpdated(e){this.refreshEditor(),this._initialized=!0}refreshEditor(){console.log("refreshEditor");this.shadowRoot.getElementById("editor")}_remove(e){e.preventDefault(),this.dispatchEvent(new CustomEvent("remove-rendition",{}))}_handleCodeChange(){this.css=this.shadowRoot.getElementById("editor").value,this.dispatchEvent(new CustomEvent("rendition-changed",{composed:!0,bubbles:!0,detail:{name:this.name,css:this.css,scope:this.scope}}))}_listchanged(e){const t=this.shadowRoot.getElementById("scopeList");this.scope=t.selected}}customElements.define("pb-odd-rendition-editor",U);class V extends f{static get styles(){return w`
|
|
619
629
|
:host {
|
|
620
630
|
display: block;
|
|
621
631
|
}
|
|
@@ -633,24 +643,32 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
633
643
|
align-self: center;
|
|
634
644
|
margin-top: 16px;
|
|
635
645
|
}
|
|
636
|
-
|
|
646
|
+
|
|
647
|
+
.editor label {
|
|
648
|
+
margin-bottom:5px;
|
|
649
|
+
font-size: 12px;
|
|
650
|
+
font-weight: 400;
|
|
651
|
+
color: var(--paper-grey-500);
|
|
652
|
+
}
|
|
653
|
+
`}render(){return y`
|
|
637
654
|
<div class="wrapper">
|
|
638
655
|
|
|
639
|
-
<paper-autocomplete id="combo" text="${this.name}" placeholder="${
|
|
656
|
+
<paper-autocomplete id="combo" text="${this.name}" placeholder="${$("odd.editor.model.param-name-placeholder")}" label="Name"
|
|
640
657
|
.source="${this._currentParameters}"></paper-autocomplete>
|
|
641
658
|
|
|
642
|
-
<
|
|
643
|
-
|
|
659
|
+
<div class="editor">
|
|
660
|
+
<label>Parameter</label>
|
|
661
|
+
<jinn-codemirror id="editor"
|
|
644
662
|
mode="xquery"
|
|
645
663
|
code="${this.value}"
|
|
646
|
-
linter="${this.endpoint}/${
|
|
647
|
-
|
|
648
|
-
<paper-checkbox id="set" ?checked="${this.setParam}" @change="${this._handleCodeChange}">${
|
|
664
|
+
linter="${this.endpoint}/${_(this.apiVersion,"1.0.0")?"modules/editor.xql":"api/lint"}"></jinn-codemirror>
|
|
665
|
+
</div>
|
|
666
|
+
<paper-checkbox id="set" ?checked="${this.setParam}" @change="${this._handleCodeChange}">${$("odd.editor.model.set-param")}</paper-checkbox>
|
|
649
667
|
<paper-icon-button @click="${this._delete}" icon="delete" title="delete this parameter"></paper-icon-button>
|
|
650
668
|
</div>
|
|
651
669
|
|
|
652
670
|
|
|
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("
|
|
671
|
+
`}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("update",this._handleCodeChange.bind(this))}refreshEditor(){this.shadowRoot.getElementById("editor")}_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").content||"",console.log("value %s",this.value),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",V);class F extends f{static get styles(){return w`
|
|
654
672
|
:host {
|
|
655
673
|
display: flex;
|
|
656
674
|
flex-direction:column;
|
|
@@ -827,10 +845,17 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
827
845
|
background:var(--paper-grey-200);
|
|
828
846
|
}
|
|
829
847
|
|
|
830
|
-
|
|
848
|
+
.editor {
|
|
831
849
|
margin-bottom: 20px;
|
|
832
850
|
}
|
|
833
851
|
|
|
852
|
+
.editor label {
|
|
853
|
+
margin-bottom:5px;
|
|
854
|
+
font-size: 12px;
|
|
855
|
+
font-weight: 400;
|
|
856
|
+
color: var(--paper-grey-500);
|
|
857
|
+
}
|
|
858
|
+
|
|
834
859
|
.horizontal {
|
|
835
860
|
display: flex;
|
|
836
861
|
flex-wrap: wrap;
|
|
@@ -840,7 +865,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
840
865
|
#mode {
|
|
841
866
|
min-width: 18em;
|
|
842
867
|
}
|
|
843
|
-
`}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
|
|
868
|
+
`}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 y`
|
|
844
869
|
<form>
|
|
845
870
|
<header>
|
|
846
871
|
<h4>
|
|
@@ -860,15 +885,15 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
860
885
|
<paper-icon-button @click="${this._paste}" icon="content-paste"
|
|
861
886
|
?hidden="${this._isModel}"></paper-icon-button>
|
|
862
887
|
|
|
863
|
-
${this._isGroupOrSequence()?
|
|
888
|
+
${this._isGroupOrSequence()?y`
|
|
864
889
|
<paper-menu-button horizontal-align="right">
|
|
865
890
|
<paper-icon-button icon="add" slot="dropdown-trigger"></paper-icon-button>
|
|
866
891
|
<paper-listbox id="modelType" slot="dropdown-content" @iron-select="${this._addNested}"
|
|
867
892
|
attr-for-selected="value">
|
|
868
|
-
${"modelSequence"===this.type?
|
|
893
|
+
${"modelSequence"===this.type?y`
|
|
869
894
|
<paper-item value="model">model</paper-item>
|
|
870
895
|
`:""}
|
|
871
|
-
${"modelGrp"===this.type?
|
|
896
|
+
${"modelGrp"===this.type?y`
|
|
872
897
|
<paper-item value="modelSequence">modelSequence</paper-item>
|
|
873
898
|
<paper-item value="model">model</paper-item>
|
|
874
899
|
`:""}
|
|
@@ -889,59 +914,62 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
889
914
|
<paper-listbox id="output" slot="dropdown-content" attr-for-selected="value"
|
|
890
915
|
selected="${this.output}" @iron-select="${this._selectOutput}">
|
|
891
916
|
|
|
892
|
-
${this.outputs.map(e=>
|
|
917
|
+
${this.outputs.map(e=>y`
|
|
893
918
|
<paper-item value="${e}">${e}</paper-item>
|
|
894
919
|
`)}
|
|
895
920
|
|
|
896
921
|
</paper-listbox>
|
|
897
922
|
</paper-dropdown-menu>
|
|
898
923
|
<paper-input id="mode" .value="${this.mode}"
|
|
899
|
-
placeholder="${
|
|
924
|
+
placeholder="${$("odd.editor.model.mode-placeholder")}"
|
|
900
925
|
label="Mode"
|
|
901
926
|
@change="${this._inputMode}"></paper-input>
|
|
902
927
|
</div>
|
|
903
|
-
<paper-input id="desc" .value="${this.desc}" placeholder="${
|
|
928
|
+
<paper-input id="desc" .value="${this.desc}" placeholder="${$("odd.editor.model.description-placeholder")}"
|
|
904
929
|
label="Description" @change="${this._inputDesc}"></paper-input>
|
|
905
930
|
|
|
906
|
-
<
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
931
|
+
<div class="editor">
|
|
932
|
+
<label>Predicate</label>
|
|
933
|
+
<jinn-codemirror id="predicate"
|
|
934
|
+
code="${this.predicate}"
|
|
935
|
+
mode="xquery"
|
|
936
|
+
linter="${this.endpoint}/${_(this.apiVersion,"1.0.0")<0?"modules/editor.xql":"api/lint"}"
|
|
937
|
+
placeholder="${$("odd.editor.model.predicate-placeholder")}"
|
|
938
|
+
@update="${this._updatePredicate}"></jinn-codemirror>
|
|
939
|
+
</div>
|
|
914
940
|
|
|
915
|
-
${this._isModel()?
|
|
941
|
+
${this._isModel()?y`
|
|
916
942
|
<div>
|
|
917
943
|
<div class="behaviourWrapper">
|
|
918
944
|
<paper-dropdown-menu label="behaviour" id="behaviourMenu" ?disabled="${this.hasCustomBehaviour}">
|
|
919
945
|
<paper-listbox id="behaviour" slot="dropdown-content" attr-for-selected="value"
|
|
920
946
|
selected="${this.behaviour}" @iron-select="${this._selectBehaviour}">
|
|
921
|
-
${this.behaviours.map(e=>
|
|
947
|
+
${this.behaviours.map(e=>y`
|
|
922
948
|
<paper-item value="${e}">${e}</paper-item>
|
|
923
949
|
`)}
|
|
924
950
|
</paper-listbox>
|
|
925
951
|
</paper-dropdown-menu>
|
|
926
|
-
<span style="align-self:center;justify-self: center;"> ${
|
|
927
|
-
<paper-input id="custombehaviour" label="" @input="${this._handleCustomBehaviour}" placeHolder="${
|
|
952
|
+
<span style="align-self:center;justify-self: center;"> ${$("odd.editor.model.link-with-or")} </span>
|
|
953
|
+
<paper-input id="custombehaviour" label="" @input="${this._handleCustomBehaviour}" placeHolder="${$("odd.editor.model.custom-behaviour-placeholder")}"></paper-input>
|
|
928
954
|
<span></span>
|
|
929
955
|
</div>
|
|
930
956
|
|
|
931
957
|
|
|
932
958
|
|
|
933
959
|
<paper-input id="css" .value="${this.css}"
|
|
934
|
-
placeholder="${
|
|
960
|
+
placeholder="${$("odd.editor.model.css-class-placeholder")}"
|
|
935
961
|
label="CSS Class"
|
|
936
962
|
@change="${this._inputCss}"></paper-input>
|
|
937
|
-
|
|
938
|
-
<
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
963
|
+
|
|
964
|
+
<div class="editor">
|
|
965
|
+
<label>Template</label>
|
|
966
|
+
<jinn-codemirror id="template"
|
|
967
|
+
code="${this.template}"
|
|
968
|
+
mode="${"latex"===this.output?"tex":"xml"}"
|
|
969
|
+
placeholder="${$("odd.editor.model.template-placeholder")}"
|
|
970
|
+
@update="${this._updateTemplate}">
|
|
971
|
+
</jinn-codemirror>
|
|
972
|
+
</div>
|
|
945
973
|
</div>
|
|
946
974
|
|
|
947
975
|
<div class="parameters">
|
|
@@ -950,7 +978,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
950
978
|
<paper-icon-button icon="add"
|
|
951
979
|
@click="${this._addParameter}"></paper-icon-button>
|
|
952
980
|
</div>
|
|
953
|
-
${
|
|
981
|
+
${z(this.parameters,e=>e.name,(e,t)=>y`
|
|
954
982
|
<pb-odd-parameter-editor
|
|
955
983
|
behaviour="${this.behaviour}"
|
|
956
984
|
name="${e.name}"
|
|
@@ -975,7 +1003,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
975
1003
|
</div>
|
|
976
1004
|
</div>
|
|
977
1005
|
|
|
978
|
-
${
|
|
1006
|
+
${z(this.renditions,e=>e.name,(e,t)=>y`
|
|
979
1007
|
<pb-odd-rendition-editor scope="${e.scope}"
|
|
980
1008
|
css="${e.css}"
|
|
981
1009
|
@remove-rendition="${e=>this._removeRendition(e,t)}"
|
|
@@ -988,7 +1016,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
988
1016
|
</iron-collapse>
|
|
989
1017
|
|
|
990
1018
|
<div class="models">
|
|
991
|
-
${
|
|
1019
|
+
${z(this.model.models,(e,t)=>y`
|
|
992
1020
|
<pb-odd-model-editor
|
|
993
1021
|
behaviour="${e.behaviour||"inline"}"
|
|
994
1022
|
predicate="${e.predicate}"
|
|
@@ -1017,7 +1045,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
1017
1045
|
</div>
|
|
1018
1046
|
</form>
|
|
1019
1047
|
<pb-message id="dialog"></pb-message>
|
|
1020
|
-
`}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.
|
|
1048
|
+
`}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._isGroupOrSequence())return console.log("asfdfa");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:[],mode:"",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(E("odd.editor.model.delete-model-label"),E("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(){this.predicate=this.shadowRoot.getElementById("predicate").value,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").value,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 f{static get styles(){return w`
|
|
1021
1049
|
:host {
|
|
1022
1050
|
display: block;
|
|
1023
1051
|
padding: 4px 10px;
|
|
@@ -1091,7 +1119,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
1091
1119
|
.models{
|
|
1092
1120
|
padding:10px;
|
|
1093
1121
|
}
|
|
1094
|
-
`}static get properties(){return{ident:{type:String},mode:{type:String},models:{type:Array},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.ident="",this.mode="",this.models=[],this.icon="expand-more"}render(){return
|
|
1122
|
+
`}static get properties(){return{ident:{type:String},mode:{type:String},models:{type:Array},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.ident="",this.mode="",this.models=[],this.icon="expand-more"}render(){return y`
|
|
1095
1123
|
<h3>
|
|
1096
1124
|
<span class="ident">${this.ident}<span class="mode">mode: ${this.mode}</span></span>
|
|
1097
1125
|
<span class="spacer"></span>
|
|
@@ -1114,7 +1142,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
1114
1142
|
</h3>
|
|
1115
1143
|
|
|
1116
1144
|
<div>
|
|
1117
|
-
${
|
|
1145
|
+
${z(this.models,(e,t)=>y`
|
|
1118
1146
|
<pb-odd-model-editor
|
|
1119
1147
|
behaviour="${e.behaviour||""}"
|
|
1120
1148
|
predicate="${e.predicate}"
|
|
@@ -1140,7 +1168,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
1140
1168
|
`)}
|
|
1141
1169
|
</div>
|
|
1142
1170
|
<pb-message id="dialog"></pb-message>
|
|
1143
|
-
`}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(
|
|
1171
|
+
`}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(E("odd.editor.model.delete-model-label"),E("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(c(x(f))){static get styles(){return w`
|
|
1144
1172
|
:host {
|
|
1145
1173
|
display: flex;
|
|
1146
1174
|
/*margin: 30px 20px;*/
|
|
@@ -1279,7 +1307,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
1279
1307
|
|
|
1280
1308
|
}
|
|
1281
1309
|
|
|
1282
|
-
`}static get properties(){return Object.assign(Object.assign({},super.properties),{},{ident:{type:String},mode:{type:String},models:{type:Array},odd:{type:String,reflect:!0},elementSpecs:{type:Array},source:{type:String},title:{type:String},titleShort:{type:String,reflect:!0,attribute:"title-short"},description:{type:String},namespace:{type:String},rootPath:{type:String,attribute:"root-path"},loading:{type:Boolean},indentString:{type:String},outputPrefix:{type:String,attribute:"output-prefix"},outputRoot:{type:String,attribute:"output-root"},currentSelection:{type:Object},useNamespace:{type:Boolean},loggedIn:{type:Boolean},tabs:{type:Array},tabIndex:{type:Number,reflect:!0}})}constructor(){super(),this.ident="",this.mode="",this.models=()=>[],this.odd="",this.elementSpecs=[],this.source="",this.title="",this.titleShort="",this.description="",this.namespace="",this.rootPath="",this.loading=!1,this.indentString=" ",this.outputPrefix="",this.outputRoot="",this.currentSelection={},this.useNamespace=!1,this.loggedIn=!0,this.tabs=[],this.tabIndex=void 0,this.selectedNavIndex=0,this.cssFile="",this.hotkeys={save:"ctrl+shift+s,command+shift+s"}}render(){return
|
|
1310
|
+
`}static get properties(){return Object.assign(Object.assign({},super.properties),{},{ident:{type:String},mode:{type:String},models:{type:Array},odd:{type:String,reflect:!0},elementSpecs:{type:Array},source:{type:String},title:{type:String},titleShort:{type:String,reflect:!0,attribute:"title-short"},description:{type:String},namespace:{type:String},rootPath:{type:String,attribute:"root-path"},loading:{type:Boolean},indentString:{type:String},outputPrefix:{type:String,attribute:"output-prefix"},outputRoot:{type:String,attribute:"output-root"},currentSelection:{type:Object},useNamespace:{type:Boolean},loggedIn:{type:Boolean},tabs:{type:Array},tabIndex:{type:Number,reflect:!0}})}constructor(){super(),this.ident="",this.mode="",this.models=()=>[],this.odd="",this.elementSpecs=[],this.source="",this.title="",this.titleShort="",this.description="",this.namespace="",this.rootPath="",this.loading=!1,this.indentString=" ",this.outputPrefix="",this.outputRoot="",this.currentSelection={},this.useNamespace=!1,this.loggedIn=!0,this.tabs=[],this.tabIndex=void 0,this.selectedNavIndex=0,this.cssFile="",this.hotkeys={save:"ctrl+shift+s,command+shift+s"}}render(){return y`
|
|
1283
1311
|
<iron-ajax id="loadContent"
|
|
1284
1312
|
handle-as="json" content-type="application/x-www-form-urlencoded"
|
|
1285
1313
|
with-credentials
|
|
@@ -1296,26 +1324,26 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
1296
1324
|
<span>${this.odd}</span>
|
|
1297
1325
|
|
|
1298
1326
|
<span class="icons">
|
|
1299
|
-
<pb-edit-xml id="editSource"><paper-icon-button icon="code" title="${
|
|
1300
|
-
<paper-icon-button @click="${this._reload}" icon="refresh" title="${
|
|
1301
|
-
<paper-icon-button @click="${this.save}" icon="save" title="${
|
|
1327
|
+
<pb-edit-xml id="editSource"><paper-icon-button icon="code" title="${$("odd.editor.odd-source")}"></paper-icon-button></pb-edit-xml>
|
|
1328
|
+
<paper-icon-button @click="${this._reload}" icon="refresh" title="${$("odd.editor.reload")}"></paper-icon-button>
|
|
1329
|
+
<paper-icon-button @click="${this.save}" icon="save" title="${$("odd.editor.save")} ${this.display("save")}"
|
|
1302
1330
|
?disabled="${!this.loggedIn}"></paper-icon-button>
|
|
1303
1331
|
</span>
|
|
1304
1332
|
</h3>
|
|
1305
1333
|
<div id="new-element" class="input-group">
|
|
1306
|
-
<paper-input id="identNew" label="${
|
|
1334
|
+
<paper-input id="identNew" label="${$("odd.editor.add-element")}" always-float-label="always-float-label">
|
|
1307
1335
|
<paper-icon-button slot="suffix" @click="${this.addElementSpec}" icon="add" tabindex="-1"></paper-icon-button>
|
|
1308
1336
|
</paper-input>
|
|
1309
1337
|
</div>
|
|
1310
1338
|
|
|
1311
1339
|
<div id="jump-to">
|
|
1312
|
-
<paper-autocomplete id="jumpTo" label="${
|
|
1340
|
+
<paper-autocomplete id="jumpTo" label="${$("odd.editor.jump-to")}" always-float-label="always-float-label"></paper-autocomplete>
|
|
1313
1341
|
</div>
|
|
1314
1342
|
|
|
1315
|
-
<h3>${
|
|
1343
|
+
<h3>${$("odd.editor.specs")}</h3>
|
|
1316
1344
|
</div>
|
|
1317
1345
|
<div id="navlist">
|
|
1318
|
-
${
|
|
1346
|
+
${z(this.elementSpecs,e=>e.ident,(e,t)=>y`
|
|
1319
1347
|
<paper-item id="es_${e.ident}"
|
|
1320
1348
|
index="${t}"
|
|
1321
1349
|
@click="${e=>this._openElementSpec(e,t)}">${e.ident}</paper-item>
|
|
@@ -1329,27 +1357,27 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
1329
1357
|
${this._computedTitle()}
|
|
1330
1358
|
</h4>
|
|
1331
1359
|
<div slot="collapse-content">
|
|
1332
|
-
<paper-input id="title" name="title" value="${this.title}" label="${
|
|
1333
|
-
placeholder="[${
|
|
1360
|
+
<paper-input id="title" name="title" value="${this.title}" label="${$("odd.editor.title")}"
|
|
1361
|
+
placeholder="[${$("odd.editor.title-placeholder")}]"
|
|
1334
1362
|
@change="${this._inputTitle}"></paper-input>
|
|
1335
|
-
<paper-input id="titleShort" name="short-title" .value="${this.titleShort}" label="${
|
|
1336
|
-
placeholder="[${
|
|
1363
|
+
<paper-input id="titleShort" name="short-title" .value="${this.titleShort}" label="${$("odd.editor.title-short")}"
|
|
1364
|
+
placeholder="[${$("odd.editor.title-short-placeholder")}]"
|
|
1337
1365
|
@change="${e=>this.titleShort=e.composedPath()[0].value}"></paper-input>
|
|
1338
|
-
<paper-input id="description" name="description" .value="${
|
|
1339
|
-
placeholder="[${
|
|
1366
|
+
<paper-input id="description" name="description" .value="${B(this.description)}" label="${$("odd.editor.description-label")}"
|
|
1367
|
+
placeholder="[${$("odd.editor.description-placeholder")}]"
|
|
1340
1368
|
@change="${e=>this.description=e.composedPath()[0].value}"></paper-input>
|
|
1341
|
-
<paper-input id="source" name="source" ?value="${this.source}" label="${
|
|
1342
|
-
placeholder="[${
|
|
1369
|
+
<paper-input id="source" name="source" ?value="${this.source}" label="${$("odd.editor.source-label")}"
|
|
1370
|
+
placeholder="[${$("odd.editor.source-placeholder")}]"
|
|
1343
1371
|
@change="${e=>this.source=e.composedPath()[0].value}"></paper-input>
|
|
1344
|
-
<paper-checkbox id="useNamespace" @change="${this.setUseNamespace}">${
|
|
1372
|
+
<paper-checkbox id="useNamespace" @change="${this.setUseNamespace}">${$("odd.editor.use-namespace")}</paper-checkbox>
|
|
1345
1373
|
<paper-input id="namespace" name="namespace" value="${this.namespace}" label="Namespace" ?disabled="${!this.useNamespace}"
|
|
1346
|
-
placeholder="[${
|
|
1374
|
+
placeholder="[${$("odd.editor.namespace-placeholder")}]"
|
|
1347
1375
|
@change="${e=>this.namespace=e.composedPath()[0].value}"></paper-input>
|
|
1348
1376
|
<div class="extCssEdit">
|
|
1349
1377
|
<paper-input name="cssFile" value="${this.cssFile}" label="External CSS File"
|
|
1350
1378
|
placeholder="[External CSS file with additional class definitions]"
|
|
1351
1379
|
@change="${this._cssFileChanged}"></paper-input>
|
|
1352
|
-
<pb-edit-xml id="editCSS"><paper-icon-button icon="create" title="${
|
|
1380
|
+
<pb-edit-xml id="editCSS"><paper-icon-button icon="create" title="${$("odd.editor.css-source")}"></paper-icon-button></pb-edit-xml>
|
|
1353
1381
|
</div>
|
|
1354
1382
|
</div>
|
|
1355
1383
|
</pb-collapse>
|
|
@@ -1359,7 +1387,7 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
1359
1387
|
|
|
1360
1388
|
<div class="editingView">
|
|
1361
1389
|
<vaadin-tabs id="tabs" selected="${this.tabIndex}">
|
|
1362
|
-
${
|
|
1390
|
+
${z(this.tabs,e=>e.id,(e,t)=>y`
|
|
1363
1391
|
<vaadin-tab name="${e}" @click="${t=>this._selectTab(t,e)}"><span style="padding-right:20px;">${e}</span><paper-icon-button icon="close" @click="${e=>this._closeTabHandler(e,t)}"></paper-icon-button></vaadin-tab>
|
|
1364
1392
|
`)}
|
|
1365
1393
|
</vaadin-tabs>
|
|
@@ -1373,4 +1401,4 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
1373
1401
|
|
|
1374
1402
|
<pb-message id="dialog" hidden></pb-message>
|
|
1375
1403
|
<pb-message id="errorMsg"></pb-message>
|
|
1376
|
-
`}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};
|
|
1404
|
+
`}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(E("browse.delete"),E("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(""),l=`${s}${r}${a}${K.serializeTemplate(o,t.template)}${n}`,d=l.length>0?`>\n${l}${e}</${t.type}`:"/";return`${e}<${t.type}${i}${d}>\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(E("odd.editor.save"),E("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(E("odd.editor.denied"),E("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(E("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(E("odd.editor.reload"),E("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};
|