| 1440 | footerDiv.querySelector('select').selectedIndex = selectedPromptIndex; | 1440 | footerDiv.querySelector('select').selectedIndex = selectedPromptIndex; |
| 1441 | | 1441 | |
| 1442 | // Add prompt export dialogue and options | 1442 | // Add prompt export dialogue and options |
| 1443 | | | |
| 1444 | const exportForCharacter = await renderTemplateAsync('promptManagerExportForCharacter'); | | |
| 1445 | const exportPopup = await renderTemplateAsync('promptManagerExportPopup', { isGlobalStrategy: 'global' === this.configuration.promptOrder.strategy, exportForCharacter }); | | |
| 1446 | rangeBlockDiv.insertAdjacentHTML('beforeend', exportPopup); | | |
| 1447 | | | |
| 1448 | // Destroy previous popper instance if it exists | | |
| 1449 | if (this.exportPopper) { | | |
| 1450 | this.exportPopper.destroy(); | | |
| 1451 | } | | |
| 1452 | | | |
| 1453 | this.exportPopper = Popper.createPopper( | | |
| 1454 | document.getElementById('prompt-manager-export'), | | |
| 1455 | document.getElementById('prompt-manager-export-format-popup'), | | |
| 1456 | { placement: 'bottom' }, | | |
| 1457 | ); | | |
| 1458 | | | |
| 1459 | const showExportSelection = () => { | | |
| 1460 | const popup = document.getElementById('prompt-manager-export-format-popup'); | | |
| 1461 | const show = popup.hasAttribute('data-show'); | | |
| 1462 | | | |
| 1463 | if (show) popup.removeAttribute('data-show'); | | |
| 1464 | else popup.setAttribute('data-show', ''); | | |
| 1465 | | | |
| 1466 | this.exportPopper.update(); | | |
| 1467 | }; | | |
| 1468 | | | |
| 1469 | footerDiv.querySelector('#prompt-manager-import').addEventListener('click', this.handleImport); | 1443 | footerDiv.querySelector('#prompt-manager-import').addEventListener('click', this.handleImport); |
| 1470 | footerDiv.querySelector('#prompt-manager-export').addEventListener('click', showExportSelection); | 1444 | footerDiv.querySelector('#prompt-manager-export').addEventListener('click', this.handleFullExport); |
| 1471 | rangeBlockDiv.querySelector('.export-promptmanager-prompts-full').addEventListener('click', this.handleFullExport); | | |
| 1472 | rangeBlockDiv.querySelector('.export-promptmanager-prompts-character')?.addEventListener('click', this.handleCharacterExport); | | |
| 1473 | } | 1445 | } |
| 1474 | } | 1446 | } |
| 1475 | | 1447 | |