ninegrid2 6.1326.0 → 6.1328.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.
@@ -28701,6 +28701,11 @@ class NxLayout2 extends HTMLElement {
28701
28701
 
28702
28702
  #originalChildren;
28703
28703
 
28704
+ static get observedAttributes() {
28705
+ // rows-height를 감시 대상에 추가
28706
+ return ['columns', 'rows-height'];
28707
+ }
28708
+
28704
28709
  constructor() {
28705
28710
  super();
28706
28711
  }
@@ -28711,16 +28716,29 @@ class NxLayout2 extends HTMLElement {
28711
28716
  }
28712
28717
 
28713
28718
  attributeChangedCallback(name, oldValue, newValue) {
28714
- if (this.#originalChildren && oldValue !== newValue) {
28715
- this.#render();
28719
+ if (oldValue !== newValue) {
28720
+ if (name === 'rows-height') {
28721
+ // 속성이 변경되면 즉시 CSS 변수에 적용
28722
+ this.#applyRowsHeight(newValue);
28723
+ }
28724
+ if (this.#originalChildren) {
28725
+ this.#render();
28726
+ }
28716
28727
  }
28717
28728
  }
28718
28729
 
28719
- static get observedAttributes() {
28720
- return ['columns'];
28730
+ #applyRowsHeight(value) {
28731
+ if (value) {
28732
+ // 콤마 제거 및 *를 1fr로 변환하는 편의 기능 추가
28733
+ const template = value.replace(/,/g, " ").replace(/\*/g, "1fr");
28734
+ this.style.setProperty('--rows-template', template);
28735
+ }
28721
28736
  }
28722
28737
 
28723
28738
  #render() {
28739
+
28740
+ this.#applyRowsHeight(this.getAttribute('rows-height'));
28741
+
28724
28742
  const children = this.#originalChildren;
28725
28743
  if (!children || children.length === 0) return;
28726
28744
 
@@ -28829,6 +28847,7 @@ class nxPanel extends nxDiv {
28829
28847
  #init = () => {
28830
28848
  const caption = this.getAttribute("caption");
28831
28849
  const columns = this.getAttribute("columns") || "";
28850
+ const rowsHeight = this.getAttribute("rows-height")?.replace(/,/g, " ") || "";
28832
28851
 
28833
28852
  const htmlTmpl = document.createElement("template");
28834
28853
  htmlTmpl.innerHTML = `
@@ -28841,7 +28860,7 @@ class nxPanel extends nxDiv {
28841
28860
  <div class="caption"><span>${caption}</span></div>
28842
28861
  </div>
28843
28862
  <div class="body">
28844
- <nx-layout2 columns="${columns}">
28863
+ <nx-layout2 columns="${columns}" rows-height="${rowsHeight}">
28845
28864
  ${this.originContents}
28846
28865
  </nx-layout2>
28847
28866
  </div>
@@ -55280,15 +55299,30 @@ class nxEditor extends nxDiv {
55280
55299
  TextAlign.configure({ types: ['heading', 'paragraph'] }),
55281
55300
  Image.configure({ inline: true, allowBase64: true }),
55282
55301
  ],
55283
- content: this.originContents || '',
55302
+ content: this.#tempValue || '',
55284
55303
  onUpdate: ({ editor }) => {
55285
55304
  this.dispatchEvent(new CustomEvent('change', { detail: editor.getHTML() }));
55286
- }
55305
+ },
55306
+ onSelectionUpdate: ({ editor }) => {
55307
+ this.#updateMenuState(editor);
55308
+ },
55287
55309
  });
55288
55310
 
55289
55311
  this.#bindEvents();
55290
55312
  }
55291
55313
 
55314
+ #updateMenuState(editor) {
55315
+ this.shadowRoot.querySelectorAll('[data-cmd]').forEach(btn => {
55316
+ if (editor.isActive(btn.dataset.cmd)) btn.classList.add('is-active');
55317
+ else btn.classList.remove('is-active');
55318
+ });
55319
+
55320
+ this.shadowRoot.querySelectorAll('[data-align]').forEach(btn => {
55321
+ if (editor.isActive({ textAlign: btn.dataset.align })) btn.classList.add('is-active');
55322
+ else btn.classList.remove('is-active');
55323
+ });
55324
+ }
55325
+
55292
55326
  #bindEvents() {
55293
55327
  const editor = this.#editor;
55294
55328
 
@@ -28697,6 +28697,11 @@ class NxLayout2 extends HTMLElement {
28697
28697
 
28698
28698
  #originalChildren;
28699
28699
 
28700
+ static get observedAttributes() {
28701
+ // rows-height를 감시 대상에 추가
28702
+ return ['columns', 'rows-height'];
28703
+ }
28704
+
28700
28705
  constructor() {
28701
28706
  super();
28702
28707
  }
@@ -28707,16 +28712,29 @@ class NxLayout2 extends HTMLElement {
28707
28712
  }
28708
28713
 
28709
28714
  attributeChangedCallback(name, oldValue, newValue) {
28710
- if (this.#originalChildren && oldValue !== newValue) {
28711
- this.#render();
28715
+ if (oldValue !== newValue) {
28716
+ if (name === 'rows-height') {
28717
+ // 속성이 변경되면 즉시 CSS 변수에 적용
28718
+ this.#applyRowsHeight(newValue);
28719
+ }
28720
+ if (this.#originalChildren) {
28721
+ this.#render();
28722
+ }
28712
28723
  }
28713
28724
  }
28714
28725
 
28715
- static get observedAttributes() {
28716
- return ['columns'];
28726
+ #applyRowsHeight(value) {
28727
+ if (value) {
28728
+ // 콤마 제거 및 *를 1fr로 변환하는 편의 기능 추가
28729
+ const template = value.replace(/,/g, " ").replace(/\*/g, "1fr");
28730
+ this.style.setProperty('--rows-template', template);
28731
+ }
28717
28732
  }
28718
28733
 
28719
28734
  #render() {
28735
+
28736
+ this.#applyRowsHeight(this.getAttribute('rows-height'));
28737
+
28720
28738
  const children = this.#originalChildren;
28721
28739
  if (!children || children.length === 0) return;
28722
28740
 
@@ -28825,6 +28843,7 @@ class nxPanel extends nxDiv {
28825
28843
  #init = () => {
28826
28844
  const caption = this.getAttribute("caption");
28827
28845
  const columns = this.getAttribute("columns") || "";
28846
+ const rowsHeight = this.getAttribute("rows-height")?.replace(/,/g, " ") || "";
28828
28847
 
28829
28848
  const htmlTmpl = document.createElement("template");
28830
28849
  htmlTmpl.innerHTML = `
@@ -28837,7 +28856,7 @@ class nxPanel extends nxDiv {
28837
28856
  <div class="caption"><span>${caption}</span></div>
28838
28857
  </div>
28839
28858
  <div class="body">
28840
- <nx-layout2 columns="${columns}">
28859
+ <nx-layout2 columns="${columns}" rows-height="${rowsHeight}">
28841
28860
  ${this.originContents}
28842
28861
  </nx-layout2>
28843
28862
  </div>
@@ -55276,15 +55295,30 @@ class nxEditor extends nxDiv {
55276
55295
  TextAlign.configure({ types: ['heading', 'paragraph'] }),
55277
55296
  Image.configure({ inline: true, allowBase64: true }),
55278
55297
  ],
55279
- content: this.originContents || '',
55298
+ content: this.#tempValue || '',
55280
55299
  onUpdate: ({ editor }) => {
55281
55300
  this.dispatchEvent(new CustomEvent('change', { detail: editor.getHTML() }));
55282
- }
55301
+ },
55302
+ onSelectionUpdate: ({ editor }) => {
55303
+ this.#updateMenuState(editor);
55304
+ },
55283
55305
  });
55284
55306
 
55285
55307
  this.#bindEvents();
55286
55308
  }
55287
55309
 
55310
+ #updateMenuState(editor) {
55311
+ this.shadowRoot.querySelectorAll('[data-cmd]').forEach(btn => {
55312
+ if (editor.isActive(btn.dataset.cmd)) btn.classList.add('is-active');
55313
+ else btn.classList.remove('is-active');
55314
+ });
55315
+
55316
+ this.shadowRoot.querySelectorAll('[data-align]').forEach(btn => {
55317
+ if (editor.isActive({ textAlign: btn.dataset.align })) btn.classList.add('is-active');
55318
+ else btn.classList.remove('is-active');
55319
+ });
55320
+ }
55321
+
55288
55322
  #bindEvents() {
55289
55323
  const editor = this.#editor;
55290
55324
 
@@ -111,15 +111,30 @@ class nxEditor extends nxDiv {
111
111
  TextAlign.configure({ types: ['heading', 'paragraph'] }),
112
112
  Image.configure({ inline: true, allowBase64: true }),
113
113
  ],
114
- content: this.originContents || '',
114
+ content: this.#tempValue || '',
115
115
  onUpdate: ({ editor }) => {
116
116
  this.dispatchEvent(new CustomEvent('change', { detail: editor.getHTML() }));
117
- }
117
+ },
118
+ onSelectionUpdate: ({ editor }) => {
119
+ this.#updateMenuState(editor);
120
+ },
118
121
  });
119
122
 
120
123
  this.#bindEvents();
121
124
  }
122
125
 
126
+ #updateMenuState(editor) {
127
+ this.shadowRoot.querySelectorAll('[data-cmd]').forEach(btn => {
128
+ if (editor.isActive(btn.dataset.cmd)) btn.classList.add('is-active');
129
+ else btn.classList.remove('is-active');
130
+ });
131
+
132
+ this.shadowRoot.querySelectorAll('[data-align]').forEach(btn => {
133
+ if (editor.isActive({ textAlign: btn.dataset.align })) btn.classList.add('is-active');
134
+ else btn.classList.remove('is-active');
135
+ });
136
+ }
137
+
123
138
  #bindEvents() {
124
139
  const editor = this.#editor;
125
140
 
@@ -4,6 +4,11 @@ class NxLayout2 extends HTMLElement {
4
4
 
5
5
  #originalChildren;
6
6
 
7
+ static get observedAttributes() {
8
+ // rows-height를 감시 대상에 추가
9
+ return ['columns', 'rows-height'];
10
+ }
11
+
7
12
  constructor() {
8
13
  super();
9
14
  }
@@ -14,16 +19,29 @@ class NxLayout2 extends HTMLElement {
14
19
  }
15
20
 
16
21
  attributeChangedCallback(name, oldValue, newValue) {
17
- if (this.#originalChildren && oldValue !== newValue) {
18
- this.#render();
22
+ if (oldValue !== newValue) {
23
+ if (name === 'rows-height') {
24
+ // 속성이 변경되면 즉시 CSS 변수에 적용
25
+ this.#applyRowsHeight(newValue);
26
+ }
27
+ if (this.#originalChildren) {
28
+ this.#render();
29
+ }
19
30
  }
20
31
  }
21
32
 
22
- static get observedAttributes() {
23
- return ['columns'];
33
+ #applyRowsHeight(value) {
34
+ if (value) {
35
+ // 콤마 제거 및 *를 1fr로 변환하는 편의 기능 추가
36
+ const template = value.replace(/,/g, " ").replace(/\*/g, "1fr");
37
+ this.style.setProperty('--rows-template', template);
38
+ }
24
39
  }
25
40
 
26
41
  #render() {
42
+
43
+ this.#applyRowsHeight(this.getAttribute('rows-height'));
44
+
27
45
  const children = this.#originalChildren;
28
46
  if (!children || children.length === 0) return;
29
47
 
@@ -14,6 +14,7 @@ class nxPanel extends nxDiv {
14
14
  #init = () => {
15
15
  const caption = this.getAttribute("caption");
16
16
  const columns = this.getAttribute("columns") || "";
17
+ const rowsHeight = this.getAttribute("rows-height")?.replace(/,/g, " ") || "";
17
18
 
18
19
  const htmlTmpl = document.createElement("template");
19
20
  htmlTmpl.innerHTML = `
@@ -26,7 +27,7 @@ class nxPanel extends nxDiv {
26
27
  <div class="caption"><span>${caption}</span></div>
27
28
  </div>
28
29
  <div class="body">
29
- <nx-layout2 columns="${columns}">
30
+ <nx-layout2 columns="${columns}" rows-height="${rowsHeight}">
30
31
  ${this.originContents}
31
32
  </nx-layout2>
32
33
  </div>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.1326.0",
4
+ "version": "6.1328.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -111,15 +111,30 @@ class nxEditor extends nxDiv {
111
111
  TextAlign.configure({ types: ['heading', 'paragraph'] }),
112
112
  Image.configure({ inline: true, allowBase64: true }),
113
113
  ],
114
- content: this.originContents || '',
114
+ content: this.#tempValue || '',
115
115
  onUpdate: ({ editor }) => {
116
116
  this.dispatchEvent(new CustomEvent('change', { detail: editor.getHTML() }));
117
- }
117
+ },
118
+ onSelectionUpdate: ({ editor }) => {
119
+ this.#updateMenuState(editor);
120
+ },
118
121
  });
119
122
 
120
123
  this.#bindEvents();
121
124
  }
122
125
 
126
+ #updateMenuState(editor) {
127
+ this.shadowRoot.querySelectorAll('[data-cmd]').forEach(btn => {
128
+ if (editor.isActive(btn.dataset.cmd)) btn.classList.add('is-active');
129
+ else btn.classList.remove('is-active');
130
+ });
131
+
132
+ this.shadowRoot.querySelectorAll('[data-align]').forEach(btn => {
133
+ if (editor.isActive({ textAlign: btn.dataset.align })) btn.classList.add('is-active');
134
+ else btn.classList.remove('is-active');
135
+ });
136
+ }
137
+
123
138
  #bindEvents() {
124
139
  const editor = this.#editor;
125
140
 
@@ -4,6 +4,11 @@ class NxLayout2 extends HTMLElement {
4
4
 
5
5
  #originalChildren;
6
6
 
7
+ static get observedAttributes() {
8
+ // rows-height를 감시 대상에 추가
9
+ return ['columns', 'rows-height'];
10
+ }
11
+
7
12
  constructor() {
8
13
  super();
9
14
  }
@@ -14,16 +19,29 @@ class NxLayout2 extends HTMLElement {
14
19
  }
15
20
 
16
21
  attributeChangedCallback(name, oldValue, newValue) {
17
- if (this.#originalChildren && oldValue !== newValue) {
18
- this.#render();
22
+ if (oldValue !== newValue) {
23
+ if (name === 'rows-height') {
24
+ // 속성이 변경되면 즉시 CSS 변수에 적용
25
+ this.#applyRowsHeight(newValue);
26
+ }
27
+ if (this.#originalChildren) {
28
+ this.#render();
29
+ }
19
30
  }
20
31
  }
21
32
 
22
- static get observedAttributes() {
23
- return ['columns'];
33
+ #applyRowsHeight(value) {
34
+ if (value) {
35
+ // 콤마 제거 및 *를 1fr로 변환하는 편의 기능 추가
36
+ const template = value.replace(/,/g, " ").replace(/\*/g, "1fr");
37
+ this.style.setProperty('--rows-template', template);
38
+ }
24
39
  }
25
40
 
26
41
  #render() {
42
+
43
+ this.#applyRowsHeight(this.getAttribute('rows-height'));
44
+
27
45
  const children = this.#originalChildren;
28
46
  if (!children || children.length === 0) return;
29
47
 
package/src/nx/nxPanel.js CHANGED
@@ -14,6 +14,7 @@ class nxPanel extends nxDiv {
14
14
  #init = () => {
15
15
  const caption = this.getAttribute("caption");
16
16
  const columns = this.getAttribute("columns") || "";
17
+ const rowsHeight = this.getAttribute("rows-height")?.replace(/,/g, " ") || "";
17
18
 
18
19
  const htmlTmpl = document.createElement("template");
19
20
  htmlTmpl.innerHTML = `
@@ -26,7 +27,7 @@ class nxPanel extends nxDiv {
26
27
  <div class="caption"><span>${caption}</span></div>
27
28
  </div>
28
29
  <div class="body">
29
- <nx-layout2 columns="${columns}">
30
+ <nx-layout2 columns="${columns}" rows-height="${rowsHeight}">
30
31
  ${this.originContents}
31
32
  </nx-layout2>
32
33
  </div>