Browse Source

Add heading in plugin settings

yoyurec 3 năm trước cách đây
mục cha
commit
3b383a918b

+ 1 - 1
libs/src/LSPlugin.ts

@@ -228,7 +228,7 @@ export type SimpleCommandKeybinding = {
 
 export type SettingSchemaDesc = {
   key: string
-  type: 'string' | 'number' | 'boolean' | 'enum' | 'object'
+  type: 'string' | 'number' | 'boolean' | 'enum' | 'object' | 'heading'
   default: string | number | boolean | Array<any> | object | null
   title: string
   description: string // support markdown

+ 7 - 1
src/main/frontend/components/plugins.css

@@ -465,6 +465,12 @@
         right: 8px;
       }
 
+      .heading-item {
+        margin: 12px 12px 6px;
+        font-weight: bold;
+        border-bottom: 1px solid var(--ls-border-color, #738694);
+      }
+
       .desc-item {
         padding: 12px 12px 6px;
 
@@ -783,7 +789,7 @@
         max-height: 80vh;
         overflow-y: auto;
       }
-      
+
       .menu-link {
         padding: 3px 5px;
       }

+ 7 - 0
src/main/frontend/components/plugins_settings.cljs

@@ -74,6 +74,12 @@
     [:small.pl-1.flex-1 description]
     [:div.pl-1 (edit-settings-file pid nil)]]])
 
+(rum/defc render-item-heading
+  [{:keys [title]}]
+
+  [:div.heading-item
+   [:h2 title]])
+
 (rum/defc settings-container
   [schema ^js pl]
   (let [^js _settings (.-settings pl)
@@ -107,6 +113,7 @@
            #{:boolean} (render-item-toggle val desc update-setting!)
            #{:enum} (render-item-enum val desc update-setting!)
            #{:object} (render-item-object val desc pid)
+           #{:heading} (render-item-heading desc)
 
            [:p (str "#Not Handled#" key)]))]