@nine-lab/nine-mu 0.1.20 → 0.1.22
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/package.json
CHANGED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { trace } from '@nine-lab/nine-util';
|
|
2
|
+
|
|
3
|
+
class NineDiffPopup extends HTMLElement {
|
|
4
|
+
#container = null;
|
|
5
|
+
#dialog = null;
|
|
6
|
+
#resolve = null;
|
|
7
|
+
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.attachShadow({ mode: 'open' });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
connectedCallback() {
|
|
14
|
+
this.render();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
render() {
|
|
18
|
+
this.shadowRoot.innerHTML = `
|
|
19
|
+
<style>
|
|
20
|
+
@import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-ai@${__APP_VERSION__}/dist/css/nine-ai.css";
|
|
21
|
+
/* nx-dialog 내부 스타일 조정 */
|
|
22
|
+
nx-dialog { --dialog-width: 90vw; --dialog-height: 85vh; }
|
|
23
|
+
.footer {
|
|
24
|
+
display: flex;
|
|
25
|
+
justify-content: flex-end;
|
|
26
|
+
gap: 10px;
|
|
27
|
+
padding: 15px;
|
|
28
|
+
background: #f9f9f9;
|
|
29
|
+
border-top: 1px solid #ddd;
|
|
30
|
+
}
|
|
31
|
+
.btn { padding: 8px 20px; cursor: pointer; border-radius: 4px; border: 1px solid #ccc; }
|
|
32
|
+
.btn.primary { background: #007bff; color: white; border: none; }
|
|
33
|
+
</style>
|
|
34
|
+
|
|
35
|
+
<nx-dialog>
|
|
36
|
+
<div style="width: 100%; height: 100%; display: flex; flex-direction: column;">
|
|
37
|
+
<div style="flex: 1; min-height: 0;">
|
|
38
|
+
<nine-diff-container id="diff-container"></nine-diff-container>
|
|
39
|
+
</div>
|
|
40
|
+
<div class="footer">
|
|
41
|
+
<button class="btn btn-cancel">취소</button>
|
|
42
|
+
<button class="btn btn-confirm primary">최종 확정 및 저장</button>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</nx-dialog>
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
this.#dialog = this.shadowRoot.querySelector('nx-dialog');
|
|
49
|
+
this.#container = this.shadowRoot.querySelector('#diff-container');
|
|
50
|
+
|
|
51
|
+
// 버튼 이벤트 바인딩
|
|
52
|
+
this.shadowRoot.querySelector('.btn-confirm').onclick = () => this.#handleConfirm();
|
|
53
|
+
this.shadowRoot.querySelector('.btn-cancel').onclick = () => this.#handleCancel();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 외부 호출용 팝업 실행 메서드
|
|
58
|
+
* @param {Object} diffData - { asis, tobe, lang }
|
|
59
|
+
* @returns {Promise<string|null>} - 확정 시 수정된 텍스트, 취소 시 null
|
|
60
|
+
*/
|
|
61
|
+
async popup(diffData) {
|
|
62
|
+
return new Promise((resolve) => {
|
|
63
|
+
this.#resolve = resolve;
|
|
64
|
+
|
|
65
|
+
// 데이터 설정 및 팝업 표시
|
|
66
|
+
this.#container.setData(diffData);
|
|
67
|
+
this.#dialog.showModal();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
#handleConfirm() {
|
|
72
|
+
const finalContent = this.#container.getContents();
|
|
73
|
+
this.#dialog.close();
|
|
74
|
+
if (this.#resolve) this.#resolve(finalContent);
|
|
75
|
+
this.remove(); // 사용 후 제거
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#handleCancel() {
|
|
79
|
+
this.#dialog.close();
|
|
80
|
+
if (this.#resolve) this.#resolve(null);
|
|
81
|
+
this.remove();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!customElements.get("nine-diff-popup")) {
|
|
86
|
+
customElements.define("nine-diff-popup", NineDiffPopup);
|
|
87
|
+
}
|