@@ -4031,22 +4031,37 @@ export class CommentActionComponent extends ActionComponent {
4031
4031
static classInfo = makeDerivedClassInfo ( ActionComponent . classInfo , {
4032
4032
flowComponentId : COMPONENT_TYPE_COMMENT_ACTION ,
4033
4033
4034
- label : ( ) => "" ,
4034
+ label : ( object : CommentActionComponent ) => object . description ,
4035
4035
4036
4036
properties : [
4037
4037
{
4038
4038
name : "text" ,
4039
4039
type : PropertyType . String ,
4040
4040
hideInPropertyGrid : true ,
4041
4041
hideInDocumentation : "all"
4042
+ } ,
4043
+ {
4044
+ name : "collapsed" ,
4045
+ type : PropertyType . Boolean ,
4046
+ hideInPropertyGrid : true ,
4047
+ hideInDocumentation : "none"
4048
+ } ,
4049
+ {
4050
+ name : "expandedWidth" ,
4051
+ type : PropertyType . Number ,
4052
+ hideInPropertyGrid : true ,
4053
+ hideInDocumentation : "none"
4042
4054
}
4043
4055
] ,
4044
4056
beforeLoadHook : (
4045
4057
object : CommentActionComponent ,
4046
4058
jsObject : Partial < CommentActionComponent >
4047
4059
) => {
4048
- if ( jsObject . description ) {
4049
- delete jsObject . description ;
4060
+ if ( jsObject . collapsed == undefined ) {
4061
+ jsObject . collapsed = false ;
4062
+ }
4063
+ if ( jsObject . expandedWidth == undefined ) {
4064
+ jsObject . expandedWidth = jsObject . width ;
4050
4065
}
4051
4066
} ,
4052
4067
icon : (
@@ -4063,37 +4078,59 @@ export class CommentActionComponent extends ActionComponent {
4063
4078
left : 0 ,
4064
4079
top : 0 ,
4065
4080
width : 435 ,
4066
- height : 134
4081
+ height : 134 ,
4082
+ collapsed : false
4083
+ } ,
4084
+ open : ( object : CommentActionComponent ) => {
4085
+ const collapsed = ! object . collapsed ;
4086
+
4087
+ if ( collapsed ) {
4088
+ ProjectEditor . getProjectStore ( object ) . updateObject ( object , {
4089
+ collapsed : ! object . collapsed ,
4090
+ expandedWidth : object . width
4091
+ } ) ;
4092
+ } else {
4093
+ ProjectEditor . getProjectStore ( object ) . updateObject ( object , {
4094
+ collapsed : ! object . collapsed ,
4095
+ width : object . expandedWidth
4096
+ } ) ;
4097
+ }
4067
4098
}
4068
4099
} ) ;
4069
4100
4070
4101
text : string ;
4102
+ collapsed : boolean ;
4103
+ expandedWidth : number ;
4071
4104
4072
4105
override makeEditable ( ) {
4073
4106
super . makeEditable ( ) ;
4074
4107
4075
4108
makeObservable ( this , {
4076
- text : observable
4109
+ text : observable ,
4110
+ collapsed : observable ,
4111
+ expandedWidth : observable
4077
4112
} ) ;
4078
4113
}
4079
4114
4080
4115
get autoSize ( ) : AutoSize {
4081
- return "height" ;
4116
+ return this . collapsed ? "both" : "height" ;
4082
4117
}
4083
4118
4084
4119
getResizeHandlers ( ) : IResizeHandler [ ] | undefined | false {
4085
- return [
4086
- {
4087
- x : 0 ,
4088
- y : 50 ,
4089
- type : "w-resize"
4090
- } ,
4091
- {
4092
- x : 100 ,
4093
- y : 50 ,
4094
- type : "e-resize"
4095
- }
4096
- ] ;
4120
+ return this . collapsed
4121
+ ? [ ]
4122
+ : [
4123
+ {
4124
+ x : 0 ,
4125
+ y : 50 ,
4126
+ type : "w-resize"
4127
+ } ,
4128
+ {
4129
+ x : 100 ,
4130
+ y : 50 ,
4131
+ type : "e-resize"
4132
+ }
4133
+ ] ;
4097
4134
}
4098
4135
4099
4136
getClassName ( flowContext : IFlowContext ) {
@@ -4105,17 +4142,19 @@ export class CommentActionComponent extends ActionComponent {
4105
4142
4106
4143
getBody ( flowContext : IFlowContext ) : React . ReactNode {
4107
4144
return (
4108
- < TrixEditor
4109
- component = { this }
4110
- flowContext = { flowContext }
4111
- value = { this . text }
4112
- setValue = { action ( ( value : string ) => {
4113
- const projectStore = getProjectStore ( this ) ;
4114
- projectStore . updateObject ( this , {
4115
- text : value
4116
- } ) ;
4117
- } ) }
4118
- > </ TrixEditor >
4145
+ ! this . collapsed && (
4146
+ < TrixEditor
4147
+ component = { this }
4148
+ flowContext = { flowContext }
4149
+ value = { this . text }
4150
+ setValue = { action ( ( value : string ) => {
4151
+ const projectStore = getProjectStore ( this ) ;
4152
+ projectStore . updateObject ( this , {
4153
+ text : value
4154
+ } ) ;
4155
+ } ) }
4156
+ > </ TrixEditor >
4157
+ )
4119
4158
) ;
4120
4159
}
4121
4160
}
0 commit comments