ninegrid2 6.1391.0 → 6.1394.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.
@@ -55221,6 +55221,8 @@ class nxEditor extends nxDiv {
55221
55221
  if (super.connectedCallback()) {
55222
55222
  this.#render();
55223
55223
  this.#initEditor();
55224
+ // 3. 초기 로드 시 readonly 상태 적용
55225
+ this.#updateEditable();
55224
55226
  }
55225
55227
  }
55226
55228
 
@@ -55263,6 +55265,34 @@ class nxEditor extends nxDiv {
55263
55265
  this.setAttribute("name", v);
55264
55266
  }
55265
55267
 
55268
+ // 1. readonly getter/setter 추가
55269
+ get readonly() {
55270
+ return this.hasAttribute("readonly");
55271
+ }
55272
+ set readonly(v) {
55273
+ if (v) {
55274
+ this.setAttribute("readonly", "");
55275
+ } else {
55276
+ this.removeAttribute("readonly");
55277
+ }
55278
+ this.#updateEditable();
55279
+ }
55280
+
55281
+ // 2. 에디터 상태 업데이트 로직 분리
55282
+ #updateEditable() {
55283
+ if (this.#editor) {
55284
+ const isReadonly = this.readonly;
55285
+ // Tiptap 에디터 편집 가능 여부 설정
55286
+ this.#editor.setEditable(!isReadonly);
55287
+
55288
+ // 메뉴바 보이기/숨기기 제어
55289
+ const menuBar = this.shadowRoot.querySelector('.menu-bar');
55290
+ if (menuBar) {
55291
+ menuBar.style.display = isReadonly ? 'none' : 'flex';
55292
+ }
55293
+ }
55294
+ }
55295
+
55266
55296
  #render() {
55267
55297
  this.shadowRoot.innerHTML = `
55268
55298
  <style>
@@ -55316,6 +55346,7 @@ class nxEditor extends nxDiv {
55316
55346
  #initEditor() {
55317
55347
  this.#editor = new Editor({
55318
55348
  element: this.#container,
55349
+ editable: !this.readonly, // 4. 생성 시 readonly 여부 반영
55319
55350
  extensions: [
55320
55351
  index_default,
55321
55352
  Underline,
@@ -55345,7 +55376,8 @@ class nxEditor extends nxDiv {
55345
55376
  this.dispatchEvent(new CustomEvent('change', { detail: editor.getHTML() }));
55346
55377
  },
55347
55378
  onSelectionUpdate: ({ editor }) => {
55348
- this.#updateMenuState(editor);
55379
+ // 5. readonly가 아닐 때만 메뉴 상태 업데이트 (성능 최적화)
55380
+ if (!this.readonly) this.#updateMenuState(editor);
55349
55381
  },
55350
55382
  });
55351
55383
 
@@ -55217,6 +55217,8 @@ class nxEditor extends nxDiv {
55217
55217
  if (super.connectedCallback()) {
55218
55218
  this.#render();
55219
55219
  this.#initEditor();
55220
+ // 3. 초기 로드 시 readonly 상태 적용
55221
+ this.#updateEditable();
55220
55222
  }
55221
55223
  }
55222
55224
 
@@ -55259,6 +55261,34 @@ class nxEditor extends nxDiv {
55259
55261
  this.setAttribute("name", v);
55260
55262
  }
55261
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
+
55262
55292
  #render() {
55263
55293
  this.shadowRoot.innerHTML = `
55264
55294
  <style>
@@ -55312,6 +55342,7 @@ class nxEditor extends nxDiv {
55312
55342
  #initEditor() {
55313
55343
  this.#editor = new Editor({
55314
55344
  element: this.#container,
55345
+ editable: !this.readonly, // 4. 생성 시 readonly 여부 반영
55315
55346
  extensions: [
55316
55347
  index_default,
55317
55348
  Underline,
@@ -55341,7 +55372,8 @@ class nxEditor extends nxDiv {
55341
55372
  this.dispatchEvent(new CustomEvent('change', { detail: editor.getHTML() }));
55342
55373
  },
55343
55374
  onSelectionUpdate: ({ editor }) => {
55344
- this.#updateMenuState(editor);
55375
+ // 5. readonly가 아닐 때만 메뉴 상태 업데이트 (성능 최적화)
55376
+ if (!this.readonly) this.#updateMenuState(editor);
55345
55377
  },
55346
55378
  });
55347
55379
 
@@ -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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.1391.0",
4
+ "version": "6.1394.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -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