ninegrid2 6.1393.0 → 6.1395.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.
@@ -28593,14 +28593,12 @@ class nxDiv extends HTMLElement {
28593
28593
  //console.log(this.innerHTML.trim());
28594
28594
  this.originContents = this.innerHTML.trim();
28595
28595
 
28596
- /**
28597
- this.originContents = this.innerHTML.trim();
28598
28596
  this.innerHTML = ""; // 기존 내부 HTML 제거
28599
28597
 
28600
28598
  // 만약 순수 nx-div로만 쓰일 경우(상속 x), 내용을 shadow에 채워줌
28601
28599
  if (this.shadowRoot && this.tagName.toLowerCase() === 'nx-div') {
28602
28600
  this.shadowRoot.innerHTML = this.originContents;
28603
- } */
28601
+ }
28604
28602
  };
28605
28603
  }
28606
28604
 
@@ -28638,10 +28636,10 @@ class nxTitle2 extends nxDiv {
28638
28636
  <span>${caption}</span>
28639
28637
  </div>
28640
28638
 
28641
- <slot></slot>
28639
+ ${this.originContents}
28642
28640
  `;
28643
28641
 
28644
- this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
28642
+ (this.shadowRoot || this).appendChild(htmlTmpl.content.cloneNode(true));
28645
28643
  }
28646
28644
  }
28647
28645
 
@@ -28900,7 +28898,7 @@ class nxPanel extends nxDiv {
28900
28898
  </div>
28901
28899
  `;
28902
28900
 
28903
- this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
28901
+ (this.shadowRoot || this).appendChild(htmlTmpl.content.cloneNode(true));
28904
28902
  }
28905
28903
  }
28906
28904
 
@@ -28918,8 +28916,6 @@ class nxButtons extends nxDiv {
28918
28916
 
28919
28917
  #init = () => {
28920
28918
 
28921
- const target = this.shadowRoot || this;
28922
-
28923
28919
  const htmlTmpl = document.createElement("template");
28924
28920
  htmlTmpl.innerHTML = `
28925
28921
  <style>
@@ -28927,10 +28923,10 @@ class nxButtons extends nxDiv {
28927
28923
  ${ninegrid.getCustomPath(this,"nxButtons.css")}
28928
28924
  </style>
28929
28925
 
28930
- <slot></slot>
28926
+ ${this.originContents}
28931
28927
  `;
28932
28928
 
28933
- target.appendChild(htmlTmpl.content.cloneNode(true));
28929
+ (this.shadowRoot || this).appendChild(htmlTmpl.content.cloneNode(true));
28934
28930
  }
28935
28931
  }
28936
28932
 
@@ -55221,6 +55217,8 @@ class nxEditor extends nxDiv {
55221
55217
  if (super.connectedCallback()) {
55222
55218
  this.#render();
55223
55219
  this.#initEditor();
55220
+ // 3. 초기 로드 시 readonly 상태 적용
55221
+ this.#updateEditable();
55224
55222
  }
55225
55223
  }
55226
55224
 
@@ -55263,6 +55261,34 @@ class nxEditor extends nxDiv {
55263
55261
  this.setAttribute("name", v);
55264
55262
  }
55265
55263
 
55264
+ // 1. readonly getter/setter 추가
55265
+ get readonly() {
55266
+ return this.hasAttribute("readonly");
55267
+ }
55268
+ set readonly(v) {
55269
+ if (v) {
55270
+ this.setAttribute("readonly", "");
55271
+ } else {
55272
+ this.removeAttribute("readonly");
55273
+ }
55274
+ this.#updateEditable();
55275
+ }
55276
+
55277
+ // 2. 에디터 상태 업데이트 로직 분리
55278
+ #updateEditable() {
55279
+ if (this.#editor) {
55280
+ const isReadonly = this.readonly;
55281
+ // Tiptap 에디터 편집 가능 여부 설정
55282
+ this.#editor.setEditable(!isReadonly);
55283
+
55284
+ // 메뉴바 보이기/숨기기 제어
55285
+ const menuBar = this.shadowRoot.querySelector('.menu-bar');
55286
+ if (menuBar) {
55287
+ menuBar.style.display = isReadonly ? 'none' : 'flex';
55288
+ }
55289
+ }
55290
+ }
55291
+
55266
55292
  #render() {
55267
55293
  this.shadowRoot.innerHTML = `
55268
55294
  <style>
@@ -55316,6 +55342,7 @@ class nxEditor extends nxDiv {
55316
55342
  #initEditor() {
55317
55343
  this.#editor = new Editor({
55318
55344
  element: this.#container,
55345
+ editable: !this.readonly, // 4. 생성 시 readonly 여부 반영
55319
55346
  extensions: [
55320
55347
  index_default,
55321
55348
  Underline,
@@ -55345,7 +55372,8 @@ class nxEditor extends nxDiv {
55345
55372
  this.dispatchEvent(new CustomEvent('change', { detail: editor.getHTML() }));
55346
55373
  },
55347
55374
  onSelectionUpdate: ({ editor }) => {
55348
- this.#updateMenuState(editor);
55375
+ // 5. readonly가 아닐 때만 메뉴 상태 업데이트 (성능 최적화)
55376
+ if (!this.readonly) this.#updateMenuState(editor);
55349
55377
  },
55350
55378
  });
55351
55379
 
@@ -28589,14 +28589,12 @@ class nxDiv extends HTMLElement {
28589
28589
  //console.log(this.innerHTML.trim());
28590
28590
  this.originContents = this.innerHTML.trim();
28591
28591
 
28592
- /**
28593
- this.originContents = this.innerHTML.trim();
28594
28592
  this.innerHTML = ""; // 기존 내부 HTML 제거
28595
28593
 
28596
28594
  // 만약 순수 nx-div로만 쓰일 경우(상속 x), 내용을 shadow에 채워줌
28597
28595
  if (this.shadowRoot && this.tagName.toLowerCase() === 'nx-div') {
28598
28596
  this.shadowRoot.innerHTML = this.originContents;
28599
- } */
28597
+ }
28600
28598
  };
28601
28599
  }
28602
28600
 
@@ -28634,10 +28632,10 @@ class nxTitle2 extends nxDiv {
28634
28632
  <span>${caption}</span>
28635
28633
  </div>
28636
28634
 
28637
- <slot></slot>
28635
+ ${this.originContents}
28638
28636
  `;
28639
28637
 
28640
- this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
28638
+ (this.shadowRoot || this).appendChild(htmlTmpl.content.cloneNode(true));
28641
28639
  }
28642
28640
  }
28643
28641
 
@@ -28896,7 +28894,7 @@ class nxPanel extends nxDiv {
28896
28894
  </div>
28897
28895
  `;
28898
28896
 
28899
- this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
28897
+ (this.shadowRoot || this).appendChild(htmlTmpl.content.cloneNode(true));
28900
28898
  }
28901
28899
  }
28902
28900
 
@@ -28914,8 +28912,6 @@ class nxButtons extends nxDiv {
28914
28912
 
28915
28913
  #init = () => {
28916
28914
 
28917
- const target = this.shadowRoot || this;
28918
-
28919
28915
  const htmlTmpl = document.createElement("template");
28920
28916
  htmlTmpl.innerHTML = `
28921
28917
  <style>
@@ -28923,10 +28919,10 @@ class nxButtons extends nxDiv {
28923
28919
  ${ninegrid.getCustomPath(this,"nxButtons.css")}
28924
28920
  </style>
28925
28921
 
28926
- <slot></slot>
28922
+ ${this.originContents}
28927
28923
  `;
28928
28924
 
28929
- target.appendChild(htmlTmpl.content.cloneNode(true));
28925
+ (this.shadowRoot || this).appendChild(htmlTmpl.content.cloneNode(true));
28930
28926
  }
28931
28927
  }
28932
28928
 
@@ -55217,6 +55213,8 @@ class nxEditor extends nxDiv {
55217
55213
  if (super.connectedCallback()) {
55218
55214
  this.#render();
55219
55215
  this.#initEditor();
55216
+ // 3. 초기 로드 시 readonly 상태 적용
55217
+ this.#updateEditable();
55220
55218
  }
55221
55219
  }
55222
55220
 
@@ -55259,6 +55257,34 @@ class nxEditor extends nxDiv {
55259
55257
  this.setAttribute("name", v);
55260
55258
  }
55261
55259
 
55260
+ // 1. readonly getter/setter 추가
55261
+ get readonly() {
55262
+ return this.hasAttribute("readonly");
55263
+ }
55264
+ set readonly(v) {
55265
+ if (v) {
55266
+ this.setAttribute("readonly", "");
55267
+ } else {
55268
+ this.removeAttribute("readonly");
55269
+ }
55270
+ this.#updateEditable();
55271
+ }
55272
+
55273
+ // 2. 에디터 상태 업데이트 로직 분리
55274
+ #updateEditable() {
55275
+ if (this.#editor) {
55276
+ const isReadonly = this.readonly;
55277
+ // Tiptap 에디터 편집 가능 여부 설정
55278
+ this.#editor.setEditable(!isReadonly);
55279
+
55280
+ // 메뉴바 보이기/숨기기 제어
55281
+ const menuBar = this.shadowRoot.querySelector('.menu-bar');
55282
+ if (menuBar) {
55283
+ menuBar.style.display = isReadonly ? 'none' : 'flex';
55284
+ }
55285
+ }
55286
+ }
55287
+
55262
55288
  #render() {
55263
55289
  this.shadowRoot.innerHTML = `
55264
55290
  <style>
@@ -55312,6 +55338,7 @@ class nxEditor extends nxDiv {
55312
55338
  #initEditor() {
55313
55339
  this.#editor = new Editor({
55314
55340
  element: this.#container,
55341
+ editable: !this.readonly, // 4. 생성 시 readonly 여부 반영
55315
55342
  extensions: [
55316
55343
  index_default,
55317
55344
  Underline,
@@ -55341,7 +55368,8 @@ class nxEditor extends nxDiv {
55341
55368
  this.dispatchEvent(new CustomEvent('change', { detail: editor.getHTML() }));
55342
55369
  },
55343
55370
  onSelectionUpdate: ({ editor }) => {
55344
- this.#updateMenuState(editor);
55371
+ // 5. readonly가 아닐 때만 메뉴 상태 업데이트 (성능 최적화)
55372
+ if (!this.readonly) this.#updateMenuState(editor);
55345
55373
  },
55346
55374
  });
55347
55375
 
package/dist/nx/_nxDiv.js CHANGED
@@ -160,13 +160,11 @@ export class nxDiv extends HTMLElement {
160
160
  //console.log(this.innerHTML.trim());
161
161
  this.originContents = this.innerHTML.trim();
162
162
 
163
- /**
164
- this.originContents = this.innerHTML.trim();
165
163
  this.innerHTML = ""; // 기존 내부 HTML 제거
166
164
 
167
165
  // 만약 순수 nx-div로만 쓰일 경우(상속 x), 내용을 shadow에 채워줌
168
166
  if (this.shadowRoot && this.tagName.toLowerCase() === 'nx-div') {
169
167
  this.shadowRoot.innerHTML = this.originContents;
170
- } */
168
+ }
171
169
  };
172
170
  }
@@ -13,8 +13,6 @@ class nxButtons extends nxDiv {
13
13
 
14
14
  #init = () => {
15
15
 
16
- const target = this.shadowRoot || this;
17
-
18
16
  const htmlTmpl = document.createElement("template");
19
17
  htmlTmpl.innerHTML = `
20
18
  <style>
@@ -22,10 +20,10 @@ class nxButtons extends nxDiv {
22
20
  ${ninegrid.getCustomPath(this,"nxButtons.css")}
23
21
  </style>
24
22
 
25
- <slot></slot>
23
+ ${this.originContents}
26
24
  `;
27
25
 
28
- target.appendChild(htmlTmpl.content.cloneNode(true));
26
+ (this.shadowRoot || this).appendChild(htmlTmpl.content.cloneNode(true));
29
27
  }
30
28
  }
31
29
 
@@ -24,6 +24,8 @@ class nxEditor extends nxDiv {
24
24
  if (super.connectedCallback()) {
25
25
  this.#render();
26
26
  this.#initEditor();
27
+ // 3. 초기 로드 시 readonly 상태 적용
28
+ this.#updateEditable();
27
29
  }
28
30
  }
29
31
 
@@ -66,6 +68,34 @@ class nxEditor extends nxDiv {
66
68
  this.setAttribute("name", v);
67
69
  }
68
70
 
71
+ // 1. readonly getter/setter 추가
72
+ get readonly() {
73
+ return this.hasAttribute("readonly");
74
+ }
75
+ set readonly(v) {
76
+ if (v) {
77
+ this.setAttribute("readonly", "");
78
+ } else {
79
+ this.removeAttribute("readonly");
80
+ }
81
+ this.#updateEditable();
82
+ }
83
+
84
+ // 2. 에디터 상태 업데이트 로직 분리
85
+ #updateEditable() {
86
+ if (this.#editor) {
87
+ const isReadonly = this.readonly;
88
+ // Tiptap 에디터 편집 가능 여부 설정
89
+ this.#editor.setEditable(!isReadonly);
90
+
91
+ // 메뉴바 보이기/숨기기 제어
92
+ const menuBar = this.shadowRoot.querySelector('.menu-bar');
93
+ if (menuBar) {
94
+ menuBar.style.display = isReadonly ? 'none' : 'flex';
95
+ }
96
+ }
97
+ }
98
+
69
99
  #render() {
70
100
  this.shadowRoot.innerHTML = `
71
101
  <style>
@@ -119,6 +149,7 @@ class nxEditor extends nxDiv {
119
149
  #initEditor() {
120
150
  this.#editor = new Editor({
121
151
  element: this.#container,
152
+ editable: !this.readonly, // 4. 생성 시 readonly 여부 반영
122
153
  extensions: [
123
154
  StarterKit,
124
155
  Underline,
@@ -148,7 +179,8 @@ class nxEditor extends nxDiv {
148
179
  this.dispatchEvent(new CustomEvent('change', { detail: editor.getHTML() }));
149
180
  },
150
181
  onSelectionUpdate: ({ editor }) => {
151
- this.#updateMenuState(editor);
182
+ // 5. readonly가 아닐 때만 메뉴 상태 업데이트 (성능 최적화)
183
+ if (!this.readonly) this.#updateMenuState(editor);
152
184
  },
153
185
  });
154
186
 
@@ -33,7 +33,7 @@ class nxPanel extends nxDiv {
33
33
  </div>
34
34
  `;
35
35
 
36
- this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
36
+ (this.shadowRoot || this).appendChild(htmlTmpl.content.cloneNode(true));
37
37
  }
38
38
  }
39
39
 
@@ -35,10 +35,10 @@ class nxTitle2 extends nxDiv {
35
35
  <span>${caption}</span>
36
36
  </div>
37
37
 
38
- <slot></slot>
38
+ ${this.originContents}
39
39
  `;
40
40
 
41
- this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
41
+ (this.shadowRoot || this).appendChild(htmlTmpl.content.cloneNode(true));
42
42
  }
43
43
  }
44
44
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.1393.0",
4
+ "version": "6.1395.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
package/src/nx/_nxDiv.js CHANGED
@@ -160,13 +160,11 @@ export class nxDiv extends HTMLElement {
160
160
  //console.log(this.innerHTML.trim());
161
161
  this.originContents = this.innerHTML.trim();
162
162
 
163
- /**
164
- this.originContents = this.innerHTML.trim();
165
163
  this.innerHTML = ""; // 기존 내부 HTML 제거
166
164
 
167
165
  // 만약 순수 nx-div로만 쓰일 경우(상속 x), 내용을 shadow에 채워줌
168
166
  if (this.shadowRoot && this.tagName.toLowerCase() === 'nx-div') {
169
167
  this.shadowRoot.innerHTML = this.originContents;
170
- } */
168
+ }
171
169
  };
172
170
  }
@@ -13,8 +13,6 @@ class nxButtons extends nxDiv {
13
13
 
14
14
  #init = () => {
15
15
 
16
- const target = this.shadowRoot || this;
17
-
18
16
  const htmlTmpl = document.createElement("template");
19
17
  htmlTmpl.innerHTML = `
20
18
  <style>
@@ -22,10 +20,10 @@ class nxButtons extends nxDiv {
22
20
  ${ninegrid.getCustomPath(this,"nxButtons.css")}
23
21
  </style>
24
22
 
25
- <slot></slot>
23
+ ${this.originContents}
26
24
  `;
27
25
 
28
- target.appendChild(htmlTmpl.content.cloneNode(true));
26
+ (this.shadowRoot || this).appendChild(htmlTmpl.content.cloneNode(true));
29
27
  }
30
28
  }
31
29
 
@@ -24,6 +24,8 @@ class nxEditor extends nxDiv {
24
24
  if (super.connectedCallback()) {
25
25
  this.#render();
26
26
  this.#initEditor();
27
+ // 3. 초기 로드 시 readonly 상태 적용
28
+ this.#updateEditable();
27
29
  }
28
30
  }
29
31
 
@@ -66,6 +68,34 @@ class nxEditor extends nxDiv {
66
68
  this.setAttribute("name", v);
67
69
  }
68
70
 
71
+ // 1. readonly getter/setter 추가
72
+ get readonly() {
73
+ return this.hasAttribute("readonly");
74
+ }
75
+ set readonly(v) {
76
+ if (v) {
77
+ this.setAttribute("readonly", "");
78
+ } else {
79
+ this.removeAttribute("readonly");
80
+ }
81
+ this.#updateEditable();
82
+ }
83
+
84
+ // 2. 에디터 상태 업데이트 로직 분리
85
+ #updateEditable() {
86
+ if (this.#editor) {
87
+ const isReadonly = this.readonly;
88
+ // Tiptap 에디터 편집 가능 여부 설정
89
+ this.#editor.setEditable(!isReadonly);
90
+
91
+ // 메뉴바 보이기/숨기기 제어
92
+ const menuBar = this.shadowRoot.querySelector('.menu-bar');
93
+ if (menuBar) {
94
+ menuBar.style.display = isReadonly ? 'none' : 'flex';
95
+ }
96
+ }
97
+ }
98
+
69
99
  #render() {
70
100
  this.shadowRoot.innerHTML = `
71
101
  <style>
@@ -119,6 +149,7 @@ class nxEditor extends nxDiv {
119
149
  #initEditor() {
120
150
  this.#editor = new Editor({
121
151
  element: this.#container,
152
+ editable: !this.readonly, // 4. 생성 시 readonly 여부 반영
122
153
  extensions: [
123
154
  StarterKit,
124
155
  Underline,
@@ -148,7 +179,8 @@ class nxEditor extends nxDiv {
148
179
  this.dispatchEvent(new CustomEvent('change', { detail: editor.getHTML() }));
149
180
  },
150
181
  onSelectionUpdate: ({ editor }) => {
151
- this.#updateMenuState(editor);
182
+ // 5. readonly가 아닐 때만 메뉴 상태 업데이트 (성능 최적화)
183
+ if (!this.readonly) this.#updateMenuState(editor);
152
184
  },
153
185
  });
154
186
 
package/src/nx/nxPanel.js CHANGED
@@ -33,7 +33,7 @@ class nxPanel extends nxDiv {
33
33
  </div>
34
34
  `;
35
35
 
36
- this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
36
+ (this.shadowRoot || this).appendChild(htmlTmpl.content.cloneNode(true));
37
37
  }
38
38
  }
39
39
 
@@ -35,10 +35,10 @@ class nxTitle2 extends nxDiv {
35
35
  <span>${caption}</span>
36
36
  </div>
37
37
 
38
- <slot></slot>
38
+ ${this.originContents}
39
39
  `;
40
40
 
41
- this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
41
+ (this.shadowRoot || this).appendChild(htmlTmpl.content.cloneNode(true));
42
42
  }
43
43
  }
44
44