3939)
4040
4141from .operators .textbox_import import (
42+ DEFAULT_CUSTOM_HEADER ,
4243 ImportFromTextboxAsCurveOperator ,
4344 ImportFromTextboxAsGreasePencilOperator ,
4445 ImportFromTextboxAsMeshOperator ,
7273# Property for custom header checkbox
7374bpy .types .WindowManager .typst_use_custom_header = bpy .props .BoolProperty (
7475 name = "Use Custom Header" ,
75- description = "Use default Typst header (page settings and text size) . If unchecked, uses the content as-is." ,
76+ description = "Prepend the custom Typst header below . If unchecked, use the content as-is." ,
7677 default = True ,
7778)
7879
80+ # The header prepended to textbox imports when enabled above.
81+ bpy .types .WindowManager .typst_custom_header = bpy .props .StringProperty (
82+ name = "Custom Header" ,
83+ description = "Typst code prepended to the textbox content before importing" ,
84+ default = DEFAULT_CUSTOM_HEADER ,
85+ )
86+
7987# Property for SVG export path (default: user's Downloads folder)
8088bpy .types .WindowManager .typst_export_filepath = bpy .props .StringProperty (
8189 name = "Export Path" ,
@@ -91,6 +99,7 @@ class VIEW3D_PT_typst_textbox_import(bpy.types.Panel):
9199 bl_region_type = "UI"
92100 bl_category = "Typst Tools"
93101 bl_label = "Typst Input"
102+ bl_order = 0
94103
95104 def draw (self , context ):
96105 layout = self .layout
@@ -103,46 +112,56 @@ def draw(self, context):
103112 box .textbox (scene , "typst_text" )
104113
105114 # Import options
106- box = layout .box ()
107- box .label (text = "Import Options" )
115+ options_box = layout .box ()
116+ options_box .label (text = "Import Options" )
108117
109118 # Origin to character option
110- box .prop (wm , "typst_origin_to_char" , text = "Origin to Character" )
119+ options_box .prop (wm , "typst_origin_to_char" , text = "Origin to Character" )
111120
112121 # Custom header option
113- box .prop (wm , "typst_use_custom_header" , text = "Use Custom Header" )
122+ options_box .prop (wm , "typst_use_custom_header" , text = "Use Custom Header" )
123+
124+ header , header_body = layout .panel (
125+ "typst_custom_header" ,
126+ default_closed = True ,
127+ )
128+ header .enabled = wm .typst_use_custom_header
129+ header .label (text = "Custom Header" , icon = "TEXT" )
130+ if header_body and wm .typst_use_custom_header :
131+ header_body .textbox (wm , "typst_custom_header" )
114132
115133 # Disable buttons if the textbox is empty
116134 has_content = bool (scene .typst_text .strip ())
117- row = box .row ()
135+ import_box = layout .box ()
136+ row = import_box .row ()
118137 row .operator (
119138 ImportFromTextboxAsUnfilledCurveOperator .bl_idname ,
120139 text = "Import as Unfilled Curve" ,
121140 icon = "CURVE_BEZCURVE" ,
122141 )
123142 row .enabled = has_content
124143
125- row = box .row ()
144+ row = import_box .row ()
126145 row .operator (
127146 ImportFromTextboxAsCurveOperator .bl_idname ,
128147 text = "Import as Curve" ,
129148 icon = "CURVE_DATA" ,
130149 )
131150 row .enabled = has_content
132151
133- row = box .row ()
152+ row = import_box .row ()
134153 row .operator (
135- ImportFromTextboxAsGreasePencilOperator .bl_idname ,
136- text = "Import as Grease Pencil " ,
137- icon = "GREASEPENCIL " ,
154+ ImportFromTextboxAsMeshOperator .bl_idname ,
155+ text = "Import as Mesh " ,
156+ icon = "MESH_DATA " ,
138157 )
139158 row .enabled = has_content
140159
141- row = box .row ()
160+ row = import_box .row ()
142161 row .operator (
143- ImportFromTextboxAsMeshOperator .bl_idname ,
144- text = "Import as Mesh " ,
145- icon = "MESH_DATA " ,
162+ ImportFromTextboxAsGreasePencilOperator .bl_idname ,
163+ text = "Import as Grease Pencil " ,
164+ icon = "GREASEPENCIL " ,
146165 )
147166 row .enabled = has_content
148167
@@ -152,7 +171,8 @@ class VIEW3D_PT_typst_animation_tools(bpy.types.Panel):
152171 bl_space_type = "VIEW_3D"
153172 bl_region_type = "UI"
154173 bl_category = "Typst Tools"
155- bl_label = "Animation Tools"
174+ bl_label = "Tools"
175+ bl_order = 10
156176
157177 def draw (self , context ):
158178 layout = self .layout
0 commit comments