Skip to content

Commit e8fe9f3

Browse files
committed
feat: 플러그인 요소 리사이징 핸들 적용 및 defineElement 설정 추가
1 parent c73750f commit e8fe9f3

7 files changed

Lines changed: 908 additions & 43 deletions

File tree

docs/plugin/declarative-api/page.mdx

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,81 @@ dmn.plugin.defineElement({
210210
2. Definition의 `resizeAnchor`
211211
3. 기본값 `"top-left"`
212212

213+
## 리사이즈 설정 (resizable, preserveAxis)
214+
215+
플러그인 요소의 크기를 사용자가 그리드에서 직접 조절할 수 있도록 하려면 `resizable` 옵션을 사용합니다.
216+
217+
### resizable
218+
219+
`resizable: true`로 설정하면 요소에 8방향 리사이즈 핸들이 표시됩니다.
220+
221+
```javascript
222+
dmn.plugin.defineElement({
223+
name: "Resizable Panel",
224+
resizable: true, // 그리드에서 크기 조절 가능
225+
// ...
226+
});
227+
```
228+
229+
<Callout type="warning">
230+
**반응형 디자인 필수**: `resizable` 옵션을 사용하려면 플러그인 내부 요소가
231+
반응형으로 디자인되어야 합니다. 고정 크기(px) 대신 상대 단위(`%`, `flex`, `fr`
232+
등)를 사용하고, 루트 요소에 `width: 100%; height: 100%`를 적용하세요. 그렇지
233+
않으면 리사이즈해도 내부 콘텐츠가 컨테이너 크기에 맞게 조절되지 않습니다.
234+
</Callout>
235+
236+
### preserveAxis
237+
238+
설정이 변경될 때 유지할 크기 축을 지정합니다. `resizable: true`일 때만 적용됩니다.
239+
240+
|| 설명 |
241+
| -------- | ---------------------------------------- |
242+
| `both` | 가로와 세로 모두 유지 (기본값) |
243+
| `width` | 가로 크기 유지, 세로는 콘텐츠에 맞춤 |
244+
| `height` | 세로 크기 유지, 가로는 콘텐츠에 맞춤 |
245+
| `none` | 둘 다 콘텐츠에 맞춤 (리사이즈 효과 리셋) |
246+
247+
```javascript
248+
dmn.plugin.defineElement({
249+
name: "KPS Panel",
250+
resizable: true,
251+
preserveAxis: "width", // 설정 변경 시 가로 크기 유지
252+
// ...
253+
});
254+
```
255+
256+
### 사용 예시
257+
258+
KPS 패널처럼 그래프 표시 옵션이 있는 경우:
259+
260+
- `preserveAxis: "width"`로 설정하면 그래프 표시를 켜고 꺼도 가로 크기는 유지됩니다
261+
- 세로 크기는 그래프 유무에 따라 자동으로 조절됩니다
262+
263+
```javascript
264+
dmn.plugin.defineElement({
265+
name: "KPS Panel",
266+
resizable: true,
267+
preserveAxis: "width",
268+
resizeAnchor: "bottom-left", // 하단 고정 (그래프가 위에서 펼쳐짐)
269+
270+
settings: {
271+
showGraph: { type: "boolean", default: true, label: "그래프 표시" },
272+
},
273+
274+
template: (state, settings, { html }) => html`
275+
<div style="width: 100%; height: 100%;">
276+
<div class="kps-value">${state.kps ?? 0}</div>
277+
${settings.showGraph ? html`<div class="graph">...</div>` : ""}
278+
</div>
279+
`,
280+
});
281+
```
282+
283+
<Callout type="tip">
284+
`resizable` 요소의 템플릿에서 루트 요소에 `width: 100%; height: 100%`
285+
적용하면 사용자가 조절한 크기에 맞게 내부 콘텐츠가 채워집니다.
286+
</Callout>
287+
213288
## 컨텍스트 메뉴 (contextMenu)
214289
215290
### 기본 설정

0 commit comments

Comments
 (0)