@teipublisher/pb-components 3.0.0-next-4.17 → 3.0.0-next-4.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.github/dependabot.yml +104 -5
  2. package/CHANGELOG.md +24 -0
  3. package/dist/demo/pb-i18n.html +4 -1
  4. package/dist/demo/pb-timeline.html +1 -1
  5. package/dist/{focus-mixin-BovUXNGZ.js → focus-mixin-BTMHjJn_.js} +1 -1
  6. package/dist/pb-code-editor.js +1 -1
  7. package/dist/pb-components-bundle.js +284 -284
  8. package/dist/{pb-dialog-DDg5xSQQ.js → pb-dialog-69GQVfpQ.js} +1 -1
  9. package/dist/pb-edit-app.js +1 -1
  10. package/dist/pb-elements.json +2063 -1445
  11. package/dist/pb-facsimile.js +4 -4
  12. package/dist/{pb-i18n-UbZecobk.js → pb-i18n-DpafwkRO.js} +1 -1
  13. package/dist/pb-leaflet-map.js +4 -4
  14. package/dist/pb-mei.js +9 -9
  15. package/dist/{pb-mixin-B7EAqf7q.js → pb-mixin-BUnZhCew.js} +1 -1
  16. package/dist/pb-odd-editor.js +1 -1
  17. package/dist/pb-tify.js +1 -1
  18. package/dist/{unsafe-html-CaP8bK29.js → unsafe-html-C8JBHfUC.js} +1 -1
  19. package/dist/url-BIkUkuPN.js +1 -0
  20. package/dist/urls-D1E6DSqS.js +1 -0
  21. package/package.json +1 -1
  22. package/pb-elements.json +2063 -1445
  23. package/src/authority/airtable.js +1 -1
  24. package/src/pb-browse-docs.js +1 -1
  25. package/src/pb-code-highlight.js +2 -1
  26. package/src/pb-combo-box.js +1 -1
  27. package/src/pb-components.js +1 -1
  28. package/src/pb-facsimile.js +1 -1
  29. package/src/pb-i18n.js +1 -1
  30. package/src/pb-leaflet-map.js +1 -1
  31. package/src/pb-login.js +1 -1
  32. package/src/pb-manage-odds.js +1 -1
  33. package/src/pb-mei.js +2 -1
  34. package/src/pb-mixin.js +47 -7
  35. package/src/pb-odd-model-editor.js +1 -1
  36. package/src/pb-odd-parameter-editor.js +1 -1
  37. package/src/pb-page.js +9 -4
  38. package/src/pb-popover.js +1 -1
  39. package/src/pb-print-preview.js +1 -1
  40. package/src/pb-table-grid.js +1 -1
  41. package/src/pb-tify.js +1 -1
  42. package/src/pb-timeline.js +2 -2
  43. package/src/pb-upload.js +1 -1
  44. package/src/pb-version.js +1 -1
  45. package/src/theming.js +2 -1
  46. package/src/urls.js +1 -1
  47. package/src/utils/css.js +29 -0
  48. package/src/{pb-events.js → utils/events.js} +1 -1
  49. package/src/{search-result-service.js → utils/services/search-result-service.js} +2 -2
  50. package/src/utils/url.js +20 -0
  51. package/src/utils/version.js +49 -0
  52. package/dist/urls-DLcxW8ou.js +0 -1
  53. package/src/utils.js +0 -53
  54. /package/src/{seed-element.js → docs/seed-element.js} +0 -0
  55. /package/src/{parse-date-service.js → utils/services/parse-date-service.js} +0 -0
@@ -1,11 +1,110 @@
1
+ # Separate entries per branch — Dependabot has no shorthand for multi-branch PR targets.
2
+ #
3
+ # Groups are evaluated in order: first matching group wins. Specific toolchains come first,
4
+ # then broad dependency-type buckets.
5
+
1
6
  version: 2
2
7
  updates:
3
- # Maintain dependencies for GitHub Actions
4
- - package-ecosystem: "github-actions"
8
+ # ─── GitHub Actions default branch (main) ─────────────────────────────────
9
+ - package-ecosystem: github-actions
5
10
  directory: "/"
6
11
  schedule:
7
- interval: "daily"
8
- - package-ecosystem: "npm"
12
+ interval: weekly
13
+ groups:
14
+ actions:
15
+ patterns:
16
+ - "*"
17
+
18
+ # ─── GitHub Actions → next-4 ────────────────────────────────────────────────
19
+ - package-ecosystem: github-actions
9
20
  directory: "/"
10
21
  schedule:
11
- interval: "daily"
22
+ interval: weekly
23
+ target-branch: next-4
24
+ groups:
25
+ actions:
26
+ patterns:
27
+ - "*"
28
+
29
+ # ─── npm → default branch (main) ────────────────────────────────────────────
30
+ - package-ecosystem: npm
31
+ directory: "/"
32
+ schedule:
33
+ interval: daily
34
+ versioning-strategy: increase-if-necessary
35
+ groups:
36
+ rollup-and-vite:
37
+ patterns:
38
+ - "rollup"
39
+ - "vite"
40
+ - "@rollup/*"
41
+ - "rollup-plugin-*"
42
+ babel:
43
+ patterns:
44
+ - "@babel/*"
45
+ cypress-and-test-tooling:
46
+ patterns:
47
+ - "cypress"
48
+ - "concurrently"
49
+ - "eslint-plugin-cypress"
50
+ - "eslint-plugin-chai-friendly"
51
+ - "web-component-analyzer"
52
+ eslint-prettier-and-lint:
53
+ patterns:
54
+ - "eslint"
55
+ - "@eslint/*"
56
+ - "eslint-*"
57
+ - "globals"
58
+ - "lint-staged"
59
+ - "@open-wc/eslint-config"
60
+ - "@open-wc/prettier-config"
61
+ semantic-release:
62
+ patterns:
63
+ - "semantic-release"
64
+ - "@semantic-release/*"
65
+ production-dependencies:
66
+ dependency-type: production
67
+ development-dependencies:
68
+ dependency-type: development
69
+
70
+ # ─── npm → next-4 (identical grouping) ──────────────────────────────────────
71
+ - package-ecosystem: npm
72
+ directory: "/"
73
+ schedule:
74
+ interval: daily
75
+ versioning-strategy: increase-if-necessary
76
+ target-branch: next-4
77
+ groups:
78
+ rollup-and-vite:
79
+ patterns:
80
+ - "rollup"
81
+ - "vite"
82
+ - "@rollup/*"
83
+ - "rollup-plugin-*"
84
+ babel:
85
+ patterns:
86
+ - "@babel/*"
87
+ cypress-and-test-tooling:
88
+ patterns:
89
+ - "cypress"
90
+ - "concurrently"
91
+ - "eslint-plugin-cypress"
92
+ - "eslint-plugin-chai-friendly"
93
+ - "web-component-analyzer"
94
+ eslint-prettier-and-lint:
95
+ patterns:
96
+ - "eslint"
97
+ - "@eslint/*"
98
+ - "eslint-*"
99
+ - "globals"
100
+ - "lint-staged"
101
+ - "@open-wc/eslint-config"
102
+ - "@open-wc/prettier-config"
103
+ semantic-release:
104
+ patterns:
105
+ - "semantic-release"
106
+ - "@semantic-release/*"
107
+ production-dependencies:
108
+ dependency-type: production
109
+ development-dependencies:
110
+ dependency-type: development
package/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ # [3.0.0-next-4.19](https://github.com/eeditiones/tei-publisher-components/compare/v3.0.0-next-4.18...v3.0.0-next-4.19) (2026-05-20)
2
+
3
+
4
+ ### chore
5
+
6
+ * **events:** reorganize event and utility imports across demo and source files ([2dddd19](https://github.com/eeditiones/tei-publisher-components/commit/2dddd19ef03b38a02a8505093802c298494abf0f))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * **events:** pb-events is gone, which affects public API
12
+
13
+ - Replaced references to the deprecated pb-events.js with the new utils/events.js in multiple demo HTML files.
14
+ - Updated various source files to import utility functions from their new locations in utils, enhancing code organization and maintainability.
15
+ - Removed the obsolete utils.js file, consolidating utility functions into more specific modules for clarity.
16
+
17
+ # [3.0.0-next-4.18](https://github.com/eeditiones/tei-publisher-components/compare/v3.0.0-next-4.17...v3.0.0-next-4.18) (2026-05-12)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **pb-i18n:** always fall back to common localization ([4906fd0](https://github.com/eeditiones/tei-publisher-components/commit/4906fd0e5bc6cda5e2780d6cc42656927ede64ab))
23
+ * **pb-i18n:** do not double-include the common locales ([fc216aa](https://github.com/eeditiones/tei-publisher-components/commit/fc216aa5ceba0d411eb25970985448168bfaf1d5))
24
+
1
25
  # [3.0.0-next-4.17](https://github.com/eeditiones/tei-publisher-components/compare/v3.0.0-next-4.16...v3.0.0-next-4.17) (2026-05-08)
2
26
 
3
27
 
@@ -60,7 +60,7 @@
60
60
  <h3 data-i18n="menu.download.title"></h3>
61
61
  <div>Attributes can be translated as well (card heading above)</div>
62
62
  </div>
63
-
63
+
64
64
  <h2>without a label</h2>
65
65
  <pb-lang label="language" selected="en" nolabel="nolabel">
66
66
  <option value="de">German</option>
@@ -73,6 +73,9 @@
73
73
  <option value="nl">Dutch</option>
74
74
  </pb-lang>
75
75
 
76
+
77
+ <h2>localizations by the system</h2>
78
+ <p>the string 'search' is localized in the common en.json to <pb-i18n id="search" key="search.search">MISSING</pb-i18n></p>
76
79
  </pb-page>
77
80
  </template>
78
81
  </pb-demo-snippet>
@@ -73,7 +73,7 @@
73
73
 
74
74
  <script type="module">
75
75
  // import { jsonDataDev } from './timeline-dev-data.js';
76
- import {SearchResultService} from "../src/search-result-service.js";
76
+ import {SearchResultService} from "../src/utils/services/search-result-service.js";
77
77
 
78
78
  /*
79
79
  const jsonData = jsonDataDev;
@@ -1,4 +1,4 @@
1
- import{E as t,p as e,a as s,x as n,i,T as o,w as r,f as a,S as l}from"./pb-mixin-B7EAqf7q.js";import{t as c}from"./pb-dialog-DDg5xSQQ.js";import{e as d,a as h,b as u,g as p,t as g}from"./pb-i18n-UbZecobk.js";import{l as f}from"./logger-BDsEU7Z8.js";import{o as m}from"./unsafe-html-CaP8bK29.js";const v=e=>e??t;class b extends(c(e(s))){static get properties(){return Object.assign(Object.assign({},super.properties),{},{noAnimation:{type:Boolean,attribute:"no-animation"},opened:{type:Boolean},toggles:{type:Boolean},expandIcon:{type:String,attribute:"expand-icon"},collapseIcon:{type:String,attribute:"collapse-icon"},iconSprite:{type:String,attribute:"icon-sprite"},noIcons:{type:Boolean,attribute:"no-icons"}})}constructor(){super(),this.horizontal=!1,this.noAnimation=!1,this.opened=!1,this.expandIcon="icons:expand-more",this.collapseIcon="icons:expand-less",this.noIcons=!1,this.toggles=!1}connectedCallback(){super.connectedCallback(),this.addEventListener("pb-collapse-open",()=>{this.open()}),this.toggles&&this.subscribeTo("pb-collapse-open",t=>{if(t.detail&&t.detail._source!==this){for(const e of this.querySelectorAll("pb-collapse"))if(e===t.detail._source)return;this.close()}})}updated(t){if(super.updated(t),t.has("opened")){const t=this.shadowRoot.querySelector("details");t&&(t.open=this.opened)}}open(){this.opened||(this.opened=!0,this.emitTo("pb-collapse-open",this))}close(){this.opened&&(this.opened=!1)}toggle(){this.opened=!this.opened,this.opened&&this.emitTo("pb-collapse-open",this.data)}_handleToggle(t){t.preventDefault(),this.toggle()}render(){return n`
1
+ import{E as t,p as e,a as s,x as n,i,T as o,w as r,f as a,S as l}from"./pb-mixin-BUnZhCew.js";import{t as c}from"./pb-dialog-69GQVfpQ.js";import{e as d,a as h,b as u,g as p,t as g}from"./pb-i18n-DpafwkRO.js";import{l as f}from"./logger-BDsEU7Z8.js";import{o as m}from"./unsafe-html-C8JBHfUC.js";const v=e=>e??t;class b extends(c(e(s))){static get properties(){return Object.assign(Object.assign({},super.properties),{},{noAnimation:{type:Boolean,attribute:"no-animation"},opened:{type:Boolean},toggles:{type:Boolean},expandIcon:{type:String,attribute:"expand-icon"},collapseIcon:{type:String,attribute:"collapse-icon"},iconSprite:{type:String,attribute:"icon-sprite"},noIcons:{type:Boolean,attribute:"no-icons"}})}constructor(){super(),this.horizontal=!1,this.noAnimation=!1,this.opened=!1,this.expandIcon="icons:expand-more",this.collapseIcon="icons:expand-less",this.noIcons=!1,this.toggles=!1}connectedCallback(){super.connectedCallback(),this.addEventListener("pb-collapse-open",()=>{this.open()}),this.toggles&&this.subscribeTo("pb-collapse-open",t=>{if(t.detail&&t.detail._source!==this){for(const e of this.querySelectorAll("pb-collapse"))if(e===t.detail._source)return;this.close()}})}updated(t){if(super.updated(t),t.has("opened")){const t=this.shadowRoot.querySelector("details");t&&(t.open=this.opened)}}open(){this.opened||(this.opened=!0,this.emitTo("pb-collapse-open",this))}close(){this.opened&&(this.opened=!1)}toggle(){this.opened=!this.opened,this.opened&&this.emitTo("pb-collapse-open",this.data)}_handleToggle(t){t.preventDefault(),this.toggle()}render(){return n`
2
2
  <details ?open="${this.opened}" class="${this.horizontal?"horizontal":""}">
3
3
  <summary
4
4
  @click="${this._handleToggle}"
@@ -1,4 +1,4 @@
1
- import{p as e,a as t,x as i,i as o}from"./pb-mixin-B7EAqf7q.js";import{J as n,X as s}from"./jinn-codemirror-DETLdm08.js";import{t as r}from"./pb-i18n-UbZecobk.js";class l{constructor(e){this.config=e}detectContext(e,t){const i=e.state.sliceDoc(Math.max(0,t-500),t),o=new RegExp(`${this.config.attributeName}\\s*=\\s*(["'])([^"']*)$`),n=i.match(o);if(!n)return{isInAttribute:!1,elementName:null,conditionValue:null};const s=i.substring(0,i.length-n[0].length).match(/<(\w+)([^>]*?)$/);if(!s)return{isInAttribute:!0,elementName:null,conditionValue:null};const r=s[1],l=s[2];let a=null;if(this.config.conditionAttribute){const e=new RegExp(`${this.config.conditionAttribute.name}\\s*=\\s*["']([^"']+)["']`),t=l.match(e);a=t?t[1]:null}return{isInAttribute:!0,elementName:r,conditionValue:a}}createCompletionSource(){return async e=>{const{state:t,pos:i,view:o}=e;if(!o)return null;const n=this.detectContext(o,i);if(n.elementName!==this.config.elementName||!n.isInAttribute)return null;if(this.config.conditionAttribute&&n.conditionValue!==this.config.conditionAttribute.value)return null;const s=t.sliceDoc(Math.max(0,i-100),i),r=new RegExp(`${this.config.attributeName}\\s*=\\s*(["'])([^"']*)$`),l=s.match(r);if(!l)return null;const a=l[2],d=a||"";return{from:i-a.length,to:i,options:await this.config.callback(d||void 0),filter:!1}}}}class a{}class d extends a{constructor(e=null){super(),this.baseUrl=e}createAutocomplete(){return new l({elementName:"ref",attributeName:"target",conditionAttribute:{name:"type",value:"biblio"},callback:this.createZoteroAutocompleteCallback()})}createZoteroAutocompleteCallback(){return async e=>{try{let t=`${this.baseUrl||""}/api/zotero/items/suggest`;e&&(t+=`?q=${encodeURIComponent(e)}`);const i=await fetch(t);if(!i.ok)return console.error("Failed to fetch Zotero suggestions:",i.status,i.statusText),[];const o=await i.json();let n=[];return Array.isArray(o)&&(n=o.map(e=>({displayLabel:e.tag,detail:e.title,label:`#${e.tag}`,type:"text",info:()=>{if(!e.bib)return null;const t=document.createElement("span");return t.innerHTML=e.bib,t}}))),console.log("Zotero suggestions:",n),n}catch(e){return console.error("Error fetching Zotero suggestions:",e),[]}}}}class h extends n{constructor(){super(),this.unwrap=!1,this.autocompleteProviders=[],this.schema=null,this.schemaRoot=null,this.baseUrl=null}connectedCallback(){var e;this.schema=this.getAttribute("schema"),this.schemaRoot=this.getAttribute("schema-root"),this.baseUrl=this.getAttribute("base-url"),this.unwrap=this.hasAttribute("unwrap"),this.autocompleteProviders=(null===(e=this.getAttribute("providers"))||void 0===e?void 0:e.split(",").map(e=>{if("zotero"===e)return new d(this.baseUrl);throw new Error(`Unknown autocomplete provider: ${e}`)}))||[],super.connectedCallback();const t=this.getAttribute("wrapper");if(t){const e=new DOMParser;let i=e.parseFromString(t,"application/xml"),o=i.getElementsByTagName("parsererror"),n=null;if(o.length)console.error("<jinn-xml-editor> Invalid XML for wrapper attribute: %s",(new XMLSerializer).serializeToString(i));else{if(n=i.firstElementChild,n&&this.hasAttribute("code")){const t=this.getAttribute("code")||"";i=e.parseFromString(t,"application/xml"),o=i.getElementsByTagName("parsererror"),o.length?console.error("<jinn-xml-editor> Invalid XML for code attribute: %s",(new XMLSerializer).serializeToString(i)):i.firstElementChild&&n.appendChild(i.firstElementChild)}this.setValue(n)}}}configure(){var e;const t=this.getToolbarControls(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("[name=toolbar]")),i=this.hasAttribute("check-namespace");this._config=new s(this,t,this.namespace,i,this.unwrap,this.autocompleteProviders.map(e=>e.createAutocomplete()))}emitUpdateEvent(e){if(!this.unwrap)return super.emitUpdateEvent(e);this.updateValue(),super.emitUpdateEvent(this._wrapper)}updateValue(){if(!this._wrapper)return console.log("no wrapper !!!"),null;if(this._wrapper.replaceChildren(),this._value)if(this._value instanceof NodeList)for(let t=0;t<this._value.length;t++){var e;const i=this._wrapper.ownerDocument.importNode(this._value[t],!0);null===(e=this._wrapper)||void 0===e||e.appendChild(i)}else{if(!(this._value instanceof Node))throw console.error("<xml-editor> Value is not a node"),new Error("value is not a node");var t;null===(t=this._wrapper)||void 0===t||t.appendChild(this._value)}else console.log("xml editor value is empty")}setValue(e){var t,i,o;if(!this.unwrap)return super.setValue(e);if((null===(t=this._config)||void 0===t?void 0:t.setFromValue(this._wrapper))===(null===(i=this._config)||void 0===i?void 0:i.setFromValue(e)))return!1;if(e||(this._wrapper=null),"string"==typeof e){const t=(new DOMParser).parseFromString(e,"application/xml");if(!t.firstElementChild)return!1;e=t.firstElementChild}return this._wrapper=e,this._value=null===(o=e)||void 0===o?void 0:o.childNodes,!0}getValue(){if(!this.unwrap)return super.getValue();if(!this._wrapper)return null;if(!(this._wrapper instanceof Element))throw new Error("Value is not a node");return this.updateValue(),this._wrapper}}customElements.get("jinn-xml-editor")||window.customElements.define("jinn-xml-editor",h);const c='\n :host {\n display: block;\n width: 100%;\n }\n jinn-codemirror {\n font-size: 1rem;\n display:block;\n width:100%;\n }\n jinn-codemirror[valid="true"] {\n outline: thin solid green;\n }\n jinn-codemirror[valid="false"] {\n outline: thin solid red;\n }\n #leiden-editor {\n margin-bottom:0.5rem;\n }\n [slot=toolbar] {\n display: flex;\n }\n .hidden {\n display: none;\n }\n #close-leiden {\n margin-left: .75rem;\n font-weight: bold;\n }',u=["Shift","Alt","Meta","Control","ArrowLeft","ArrowRight","ArrowDown","ArrowUp","PageDown","PageUp","Home","End"],m={leiden_plus:"Leiden+",edcs:"EDCS/EDH",default:"Petrae"};function p(e){const t=[];return Object.entries(m).forEach(([i,o])=>{t.push(`<option value="${i}" ${i===e?"selected":""}>${o}</option>`)}),`<select name="modes">${t.join("\n")}</select>`}class v extends HTMLElement{constructor(){super(),this.mode="leiden_plus",this.placeholder="",this.showLeiden=!1,this.xmlEditor=null,this.valid=!0,this.unwrap=!1,this.schema=null,this.schemaRoot=null,this.modeSelect=!1,this.attachShadow({mode:"open"})}set value(e){this.xmlEditor.value=e}get value(){return this.xmlEditor.value}connectedCallback(){var e,t,i,o;this.unwrap=this.hasAttribute("unwrap"),this.schema=this.getAttribute("schema"),this.schemaRoot=this.getAttribute("schema-root"),this.modeSelect=this.hasAttribute("mode-select"),this.mode=this.getAttribute("mode")||"leiden_plus",this.placeholder=this.getAttribute("placeholder")||"",this.showLeiden=this.hasAttribute("show-leiden"),this.shadowRoot.innerHTML=`\n <style>\n ${c}\n </style>\n <jinn-codemirror id="leiden-editor" class="${this.showLeiden?"":"hidden"}" \n mode="${this.mode}" ignore-blur>\n <div slot="header"><slot name="leiden-header"></slot></div>\n <div slot="toolbar">\n ${this.modeSelect?p(this.mode):""}\n <slot name="leiden-toolbar"></slot>\n <button part="button" id="close-leiden">Close</button>\n </div>\n </jinn-codemirror>\n <jinn-xml-editor id="xml-editor" ${this.unwrap?"unwrap":""} schema="${this.schema}"\n schema-root="${this.schemaRoot}" placeholder="${this.placeholder}" ignore-blur\n namespace="http://www.tei-c.org/ns/1.0">\n <div slot="header"><slot name="xml-header"></slot></div>\n <div slot="toolbar">\n <slot name="open-leiden" id="import" class="${this.showLeiden?"hidden":""}">\n <button part="button" title="Import from Leiden markup">Leiden Editor</button>\n </slot>\n <slot name="xml-toolbar"></slot>\n </div>\n </jinn-xml-editor>\n `,this.xmlEditor=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#xml-editor");const n=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("#leiden-editor"),s=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelector("#import"),r=null===(o=this.shadowRoot)||void 0===o?void 0:o.querySelector("#close-leiden");if(!(this.xmlEditor&&n&&s&&r))throw new Error("One or more components were not initialized");let l=!0,a=this.showLeiden;n.addEventListener("update",e=>{e.stopPropagation(),this.showLeiden=!1,l&&(this.xmlEditor.content=e.detail.content),l=!0}),this.xmlEditor.addEventListener("keyup",e=>{if(a){if(u.indexOf(e.key)>-1)return;h()}});const d=()=>{s.classList.add("hidden"),n.classList.remove("hidden"),a=!0,n.focus()},h=()=>{var e;n.classList.add("hidden"),s.classList.remove("hidden"),a=!1,null===(e=this.xmlEditor)||void 0===e||e.focus(),l=!1,null==n||n.clear()},m=()=>{if(n.classList.contains("hidden")||this.showLeiden)if(this.xmlEditor.content.length>0){var e;if(!this.valid)return void alert("The XML contains errors. Cannot convert to Leiden+");const t=null===(e=this.xmlEditor)||void 0===e?void 0:e.value;l=!1,n.setMode("leiden_plus",!1);try{this.unwrap&&t instanceof Element?n.value=t.childNodes:n.value=t,this.xmlEditor.status="",d()}catch(e){this.xmlEditor.status=e.message,h()}}else d(),n.value="";else h()};s.addEventListener("click",()=>{m()}),r.addEventListener("click",()=>{h()}),this.xmlEditor.addEventListener("invalid",e=>{e.stopPropagation(),this.valid=!1,this.setAttribute("valid",this.valid.toString()),this.dispatchEvent(new CustomEvent("invalid",{detail:e.detail,composed:!0,bubbles:!0}))}),this.xmlEditor.addEventListener("valid",e=>{e.stopPropagation(),this.valid=!0,this.setAttribute("valid",this.valid.toString()),this.dispatchEvent(new CustomEvent("valid",{detail:e.detail,composed:!0,bubbles:!0}))}),this.xmlEditor.addEventListener("update",()=>{this.showLeiden&&m(),this.showLeiden=!1},{once:!0}),this.addEventListener("blur",e=>{e.relatedTarget&&!this.contains(e.relatedTarget)&&this.dispatchEvent(new CustomEvent("leave",{composed:!0,bubbles:!0}))})}}customElements.get("jinn-epidoc-editor")||window.customElements.define("jinn-epidoc-editor",v);class b extends(e(t)){static get properties(){return Object.assign(Object.assign({},super.properties),{},{code:{type:String,reflect:!0},mode:{type:String},label:{type:String},placeholder:{type:String},tabSize:{type:Number},linter:{attribute:!0}})}constructor(){super(),this.code="",this.mode="xml",this.placeholder="odd.editor.model.empty",this.tabSize=2,this.label="",this.linter="",this._editor=null}connectedCallback(){super.connectedCallback()}firstUpdated(){super.firstUpdated(),this._editor=this.shadowRoot.getElementById("editor")}render(){return i`
1
+ import{p as e,a as t,x as i,i as o}from"./pb-mixin-BUnZhCew.js";import{J as n,X as s}from"./jinn-codemirror-DETLdm08.js";import{t as r}from"./pb-i18n-DpafwkRO.js";class l{constructor(e){this.config=e}detectContext(e,t){const i=e.state.sliceDoc(Math.max(0,t-500),t),o=new RegExp(`${this.config.attributeName}\\s*=\\s*(["'])([^"']*)$`),n=i.match(o);if(!n)return{isInAttribute:!1,elementName:null,conditionValue:null};const s=i.substring(0,i.length-n[0].length).match(/<(\w+)([^>]*?)$/);if(!s)return{isInAttribute:!0,elementName:null,conditionValue:null};const r=s[1],l=s[2];let a=null;if(this.config.conditionAttribute){const e=new RegExp(`${this.config.conditionAttribute.name}\\s*=\\s*["']([^"']+)["']`),t=l.match(e);a=t?t[1]:null}return{isInAttribute:!0,elementName:r,conditionValue:a}}createCompletionSource(){return async e=>{const{state:t,pos:i,view:o}=e;if(!o)return null;const n=this.detectContext(o,i);if(n.elementName!==this.config.elementName||!n.isInAttribute)return null;if(this.config.conditionAttribute&&n.conditionValue!==this.config.conditionAttribute.value)return null;const s=t.sliceDoc(Math.max(0,i-100),i),r=new RegExp(`${this.config.attributeName}\\s*=\\s*(["'])([^"']*)$`),l=s.match(r);if(!l)return null;const a=l[2],d=a||"";return{from:i-a.length,to:i,options:await this.config.callback(d||void 0),filter:!1}}}}class a{}class d extends a{constructor(e=null){super(),this.baseUrl=e}createAutocomplete(){return new l({elementName:"ref",attributeName:"target",conditionAttribute:{name:"type",value:"biblio"},callback:this.createZoteroAutocompleteCallback()})}createZoteroAutocompleteCallback(){return async e=>{try{let t=`${this.baseUrl||""}/api/zotero/items/suggest`;e&&(t+=`?q=${encodeURIComponent(e)}`);const i=await fetch(t);if(!i.ok)return console.error("Failed to fetch Zotero suggestions:",i.status,i.statusText),[];const o=await i.json();let n=[];return Array.isArray(o)&&(n=o.map(e=>({displayLabel:e.tag,detail:e.title,label:`#${e.tag}`,type:"text",info:()=>{if(!e.bib)return null;const t=document.createElement("span");return t.innerHTML=e.bib,t}}))),console.log("Zotero suggestions:",n),n}catch(e){return console.error("Error fetching Zotero suggestions:",e),[]}}}}class h extends n{constructor(){super(),this.unwrap=!1,this.autocompleteProviders=[],this.schema=null,this.schemaRoot=null,this.baseUrl=null}connectedCallback(){var e;this.schema=this.getAttribute("schema"),this.schemaRoot=this.getAttribute("schema-root"),this.baseUrl=this.getAttribute("base-url"),this.unwrap=this.hasAttribute("unwrap"),this.autocompleteProviders=(null===(e=this.getAttribute("providers"))||void 0===e?void 0:e.split(",").map(e=>{if("zotero"===e)return new d(this.baseUrl);throw new Error(`Unknown autocomplete provider: ${e}`)}))||[],super.connectedCallback();const t=this.getAttribute("wrapper");if(t){const e=new DOMParser;let i=e.parseFromString(t,"application/xml"),o=i.getElementsByTagName("parsererror"),n=null;if(o.length)console.error("<jinn-xml-editor> Invalid XML for wrapper attribute: %s",(new XMLSerializer).serializeToString(i));else{if(n=i.firstElementChild,n&&this.hasAttribute("code")){const t=this.getAttribute("code")||"";i=e.parseFromString(t,"application/xml"),o=i.getElementsByTagName("parsererror"),o.length?console.error("<jinn-xml-editor> Invalid XML for code attribute: %s",(new XMLSerializer).serializeToString(i)):i.firstElementChild&&n.appendChild(i.firstElementChild)}this.setValue(n)}}}configure(){var e;const t=this.getToolbarControls(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("[name=toolbar]")),i=this.hasAttribute("check-namespace");this._config=new s(this,t,this.namespace,i,this.unwrap,this.autocompleteProviders.map(e=>e.createAutocomplete()))}emitUpdateEvent(e){if(!this.unwrap)return super.emitUpdateEvent(e);this.updateValue(),super.emitUpdateEvent(this._wrapper)}updateValue(){if(!this._wrapper)return console.log("no wrapper !!!"),null;if(this._wrapper.replaceChildren(),this._value)if(this._value instanceof NodeList)for(let t=0;t<this._value.length;t++){var e;const i=this._wrapper.ownerDocument.importNode(this._value[t],!0);null===(e=this._wrapper)||void 0===e||e.appendChild(i)}else{if(!(this._value instanceof Node))throw console.error("<xml-editor> Value is not a node"),new Error("value is not a node");var t;null===(t=this._wrapper)||void 0===t||t.appendChild(this._value)}else console.log("xml editor value is empty")}setValue(e){var t,i,o;if(!this.unwrap)return super.setValue(e);if((null===(t=this._config)||void 0===t?void 0:t.setFromValue(this._wrapper))===(null===(i=this._config)||void 0===i?void 0:i.setFromValue(e)))return!1;if(e||(this._wrapper=null),"string"==typeof e){const t=(new DOMParser).parseFromString(e,"application/xml");if(!t.firstElementChild)return!1;e=t.firstElementChild}return this._wrapper=e,this._value=null===(o=e)||void 0===o?void 0:o.childNodes,!0}getValue(){if(!this.unwrap)return super.getValue();if(!this._wrapper)return null;if(!(this._wrapper instanceof Element))throw new Error("Value is not a node");return this.updateValue(),this._wrapper}}customElements.get("jinn-xml-editor")||window.customElements.define("jinn-xml-editor",h);const c='\n :host {\n display: block;\n width: 100%;\n }\n jinn-codemirror {\n font-size: 1rem;\n display:block;\n width:100%;\n }\n jinn-codemirror[valid="true"] {\n outline: thin solid green;\n }\n jinn-codemirror[valid="false"] {\n outline: thin solid red;\n }\n #leiden-editor {\n margin-bottom:0.5rem;\n }\n [slot=toolbar] {\n display: flex;\n }\n .hidden {\n display: none;\n }\n #close-leiden {\n margin-left: .75rem;\n font-weight: bold;\n }',u=["Shift","Alt","Meta","Control","ArrowLeft","ArrowRight","ArrowDown","ArrowUp","PageDown","PageUp","Home","End"],m={leiden_plus:"Leiden+",edcs:"EDCS/EDH",default:"Petrae"};function p(e){const t=[];return Object.entries(m).forEach(([i,o])=>{t.push(`<option value="${i}" ${i===e?"selected":""}>${o}</option>`)}),`<select name="modes">${t.join("\n")}</select>`}class v extends HTMLElement{constructor(){super(),this.mode="leiden_plus",this.placeholder="",this.showLeiden=!1,this.xmlEditor=null,this.valid=!0,this.unwrap=!1,this.schema=null,this.schemaRoot=null,this.modeSelect=!1,this.attachShadow({mode:"open"})}set value(e){this.xmlEditor.value=e}get value(){return this.xmlEditor.value}connectedCallback(){var e,t,i,o;this.unwrap=this.hasAttribute("unwrap"),this.schema=this.getAttribute("schema"),this.schemaRoot=this.getAttribute("schema-root"),this.modeSelect=this.hasAttribute("mode-select"),this.mode=this.getAttribute("mode")||"leiden_plus",this.placeholder=this.getAttribute("placeholder")||"",this.showLeiden=this.hasAttribute("show-leiden"),this.shadowRoot.innerHTML=`\n <style>\n ${c}\n </style>\n <jinn-codemirror id="leiden-editor" class="${this.showLeiden?"":"hidden"}" \n mode="${this.mode}" ignore-blur>\n <div slot="header"><slot name="leiden-header"></slot></div>\n <div slot="toolbar">\n ${this.modeSelect?p(this.mode):""}\n <slot name="leiden-toolbar"></slot>\n <button part="button" id="close-leiden">Close</button>\n </div>\n </jinn-codemirror>\n <jinn-xml-editor id="xml-editor" ${this.unwrap?"unwrap":""} schema="${this.schema}"\n schema-root="${this.schemaRoot}" placeholder="${this.placeholder}" ignore-blur\n namespace="http://www.tei-c.org/ns/1.0">\n <div slot="header"><slot name="xml-header"></slot></div>\n <div slot="toolbar">\n <slot name="open-leiden" id="import" class="${this.showLeiden?"hidden":""}">\n <button part="button" title="Import from Leiden markup">Leiden Editor</button>\n </slot>\n <slot name="xml-toolbar"></slot>\n </div>\n </jinn-xml-editor>\n `,this.xmlEditor=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#xml-editor");const n=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("#leiden-editor"),s=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelector("#import"),r=null===(o=this.shadowRoot)||void 0===o?void 0:o.querySelector("#close-leiden");if(!(this.xmlEditor&&n&&s&&r))throw new Error("One or more components were not initialized");let l=!0,a=this.showLeiden;n.addEventListener("update",e=>{e.stopPropagation(),this.showLeiden=!1,l&&(this.xmlEditor.content=e.detail.content),l=!0}),this.xmlEditor.addEventListener("keyup",e=>{if(a){if(u.indexOf(e.key)>-1)return;h()}});const d=()=>{s.classList.add("hidden"),n.classList.remove("hidden"),a=!0,n.focus()},h=()=>{var e;n.classList.add("hidden"),s.classList.remove("hidden"),a=!1,null===(e=this.xmlEditor)||void 0===e||e.focus(),l=!1,null==n||n.clear()},m=()=>{if(n.classList.contains("hidden")||this.showLeiden)if(this.xmlEditor.content.length>0){var e;if(!this.valid)return void alert("The XML contains errors. Cannot convert to Leiden+");const t=null===(e=this.xmlEditor)||void 0===e?void 0:e.value;l=!1,n.setMode("leiden_plus",!1);try{this.unwrap&&t instanceof Element?n.value=t.childNodes:n.value=t,this.xmlEditor.status="",d()}catch(e){this.xmlEditor.status=e.message,h()}}else d(),n.value="";else h()};s.addEventListener("click",()=>{m()}),r.addEventListener("click",()=>{h()}),this.xmlEditor.addEventListener("invalid",e=>{e.stopPropagation(),this.valid=!1,this.setAttribute("valid",this.valid.toString()),this.dispatchEvent(new CustomEvent("invalid",{detail:e.detail,composed:!0,bubbles:!0}))}),this.xmlEditor.addEventListener("valid",e=>{e.stopPropagation(),this.valid=!0,this.setAttribute("valid",this.valid.toString()),this.dispatchEvent(new CustomEvent("valid",{detail:e.detail,composed:!0,bubbles:!0}))}),this.xmlEditor.addEventListener("update",()=>{this.showLeiden&&m(),this.showLeiden=!1},{once:!0}),this.addEventListener("blur",e=>{e.relatedTarget&&!this.contains(e.relatedTarget)&&this.dispatchEvent(new CustomEvent("leave",{composed:!0,bubbles:!0}))})}}customElements.get("jinn-epidoc-editor")||window.customElements.define("jinn-epidoc-editor",v);class b extends(e(t)){static get properties(){return Object.assign(Object.assign({},super.properties),{},{code:{type:String,reflect:!0},mode:{type:String},label:{type:String},placeholder:{type:String},tabSize:{type:Number},linter:{attribute:!0}})}constructor(){super(),this.code="",this.mode="xml",this.placeholder="odd.editor.model.empty",this.tabSize=2,this.label="",this.linter="",this._editor=null}connectedCallback(){super.connectedCallback()}firstUpdated(){super.firstUpdated(),this._editor=this.shadowRoot.getElementById("editor")}render(){return i`
2
2
  <div class="label">${this.label}</div>
3
3
  <jinn-codemirror
4
4
  id="editor"