feat: 플러그인 설정 스키마에 조건부 표시(visible) 지원#52
Merged
lee-sihun merged 4 commits intoDmNote-App:masterfrom Mar 1, 2026
Merged
Conversation
added 4 commits
March 1, 2026 19:13
플러그인 설정 항목이 다른 설정값에 따라 동적으로 표시/숨김 가능하도록
PluginSettingSchema에 `when` 속성을 추가한다.
## 해결하는 문제
플러그인이 여러 모드를 지원할 때(예: 게임 구동기 선택) 특정 모드에서만
유효한 설정이 항상 노출되어 사용자에게 혼란을 줌.
기존 API에는 설정의 조건부 표시/숨기기 기능이 없었음.
## 변경 내용
- `PluginSettingSchema` 타입에 `when?: { key, value?, not? }` 속성 추가
- `when: { key: "mode", value: "A" }` -> mode가 A일 때만 표시
- `when: { key: "mode", not: "B" }` -> mode가 B가 아닐 때 표시
- value/not에 배열을 넣으면 OR 매칭 지원
- divider 타입에도 적용 가능
- 패널 모드(PropertiesPanel.tsx): 렌더 시 when 조건 평가, 미충족 시
해당 항목을 렌더링하지 않음. React 리렌더 사이클에 의해 자동 반영.
- 모달 모드(defineSettings.ts): 초기 빌드 시 display:none 적용,
설정 변경마다 _updateVisibility()로 DOM visibility 동기화.
- 숨겨진 설정의 저장값은 유지됨 (표시만 제어, 데이터 손실 없음)
PluginSettingWhenCondition 타입을 별도 정의하여 value/not 필드를 string | number | boolean 유니온으로 제한. 잘못된 타입의 조건값이 컴파일 타임에 검출되도록 한다.
defineElement.ts의 openInstanceSettings() 모달 렌더링 경로에 when 조건 체크가 누락되어 있었음. 이로 인해 엘리먼트 설정을 모달로 열 때는 조건부 visibility가 동작하지 않았음.
PluginMenuItem의 기존 visible?: boolean | ((ctx) => boolean) 패턴과 일관성을 맞추기 위해 설정 스키마의 when 객체를 visible로 변경. PluginSettingWhenCondition 타입 제거, 4개 렌더링 경로 모두 반영.
Author
|
뭐 뭣 이렇게 빨리 머지 시켜주신다고요? |
Member
|
@all-contributors add @dotoritos-kim for code 기여 감사합니다! 하위 호환성이랑 API 일관성까지 신경 써 주셔서 바로 병합 했습니다. |
Member
|
@all-contributors add @dotoritos-kim for code |
Contributor
|
I've put up a pull request to add @dotoritos-kim! 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
동기
현재 플러그인 설정 스키마(
defineSettings,defineElement)에서 정의한 항목은모두 무조건 표시됩니다. 특정 설정값에 따라 관련 없는 항목을 숨기는 것이 불가능합니다.
현재 상태
id,data-*)가 없어 플러그인이 CSS/DOM으로 개별 행을 선택할 수 없음visible/disabled속성이 존재하지만, 설정 스키마에는 동등한 기능이 없음내장 플러그인의 실제 사례
kps.js에서showGraph: false일 때 그래프 관련 설정 4개(graphType,graphSpeed,graphColor,graphDivider)가 무의미하게 노출됨:변경 내용
PluginSettingSchema에 optionalvisible속성을 추가합니다.기존
PluginMenuItem의visible패턴과 동일한 시그니처를 사용합니다.kps.js에 적용하면
적용 범위
설정이 렌더링되는 4개 경로 모두에 적용했습니다:
PropertiesPanel.tsxdefineSettings.tsPropertiesPanel.tsx(동일 함수)defineElement.ts하위 호환성
visible은 optional 속성이므로, 기존 플러그인은 코드 변경 없이 동일하게 동작합니다visible이 없는 설정은 모든 경로에서 무조건 표시됩니다 (기존 동작)API 일관성
컨텍스트 메뉴의
PluginMenuItem에 이미 존재하는visible패턴과 동일한 시그니처를 사용합니다:타입 정의
이 작업으로 할 수 있는 것들 예측
키 입력 통계
visible없이는 항상 모든 항목이 노출됨날씨 위젯
포모도로 타이머
음악 플레이어 연동
채팅 오버레이
공통점
visible없이는 모든 설정이 항상 보여서 사용자가 혼란스럽거나,플러그인 개발자가 별도 모달을 직접 구현해야 함