Skip to content

Commit 0b7c28d

Browse files
committed
1 parent 5923cd7 commit 0b7c28d

File tree

6 files changed

+87
-31
lines changed

6 files changed

+87
-31
lines changed

packages/eez-studio-ui/_stylesheets/project-editor.less

+1
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,7 @@
11751175

11761176
.title-enclosure {
11771177
overflow: hidden;
1178+
min-width: 0px;
11781179

11791180
svg {
11801181
fill-opacity: 30%;

packages/project-editor/flow/component.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -4061,6 +4061,14 @@ function renderActionComponent(
40614061
{executionStateInfo}
40624062
<span className="title-text">{getLabel(actionNode)}</span>
40634063
</div>
4064+
{actionNode instanceof
4065+
ProjectEditor.CommentActionComponentClass &&
4066+
actionNode.collapsed && (
4067+
<Icon
4068+
icon="material:arrow_drop_down"
4069+
style={{ opacity: 0.5 }}
4070+
/>
4071+
)}
40644072
{seqOutputIndex != -1 && (
40654073
<ComponentOutputSpan
40664074
componentOutput={actionNode.outputs[seqOutputIndex]}

packages/project-editor/flow/components/actions/index.tsx

+68-29
Original file line numberDiff line numberDiff line change
@@ -4031,22 +4031,37 @@ export class CommentActionComponent extends ActionComponent {
40314031
static classInfo = makeDerivedClassInfo(ActionComponent.classInfo, {
40324032
flowComponentId: COMPONENT_TYPE_COMMENT_ACTION,
40334033

4034-
label: () => "",
4034+
label: (object: CommentActionComponent) => object.description,
40354035

40364036
properties: [
40374037
{
40384038
name: "text",
40394039
type: PropertyType.String,
40404040
hideInPropertyGrid: true,
40414041
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"
40424054
}
40434055
],
40444056
beforeLoadHook: (
40454057
object: CommentActionComponent,
40464058
jsObject: Partial<CommentActionComponent>
40474059
) => {
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;
40504065
}
40514066
},
40524067
icon: (
@@ -4063,37 +4078,59 @@ export class CommentActionComponent extends ActionComponent {
40634078
left: 0,
40644079
top: 0,
40654080
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+
}
40674098
}
40684099
});
40694100

40704101
text: string;
4102+
collapsed: boolean;
4103+
expandedWidth: number;
40714104

40724105
override makeEditable() {
40734106
super.makeEditable();
40744107

40754108
makeObservable(this, {
4076-
text: observable
4109+
text: observable,
4110+
collapsed: observable,
4111+
expandedWidth: observable
40774112
});
40784113
}
40794114

40804115
get autoSize(): AutoSize {
4081-
return "height";
4116+
return this.collapsed ? "both" : "height";
40824117
}
40834118

40844119
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+
];
40974134
}
40984135

40994136
getClassName(flowContext: IFlowContext) {
@@ -4105,17 +4142,19 @@ export class CommentActionComponent extends ActionComponent {
41054142

41064143
getBody(flowContext: IFlowContext): React.ReactNode {
41074144
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+
)
41194158
);
41204159
}
41214160
}

packages/project-editor/flow/editor/render.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,10 @@ export const ComponentEnclosure = observer(
396396
// component description
397397
component instanceof
398398
ProjectEditor.ActionComponentClass &&
399+
!(
400+
component instanceof
401+
ProjectEditor.CommentActionComponentClass
402+
) &&
399403
component.description &&
400404
flowContext.projectStore.uiStateStore
401405
.showComponentDescriptions &&

packages/project-editor/project-editor-create.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ import { getObjectVariableTypeFromType } from "project-editor/features/variable/
4545
// ACTIONS
4646
import {
4747
OutputActionComponent,
48-
CallActionActionComponent
48+
CallActionActionComponent,
49+
CommentActionComponent
4950
} from "project-editor/flow/components/actions";
5051
import "project-editor/flow/components/actions/execute-command";
5152
import "project-editor/flow/components/actions/stream";
@@ -174,6 +175,7 @@ export async function createProjectEditor(
174175
ActionClass: Action,
175176
ComponentClass: Component,
176177
ActionComponentClass: ActionComponent,
178+
CommentActionComponentClass: CommentActionComponent,
177179
WidgetClass: Widget,
178180
ConnectionLineClass: ConnectionLine,
179181
UserWidgetWidgetClass: UserWidgetWidget,

packages/project-editor/project-editor-interface.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ import type { browseGlyph } from "project-editor/features/font/FontEditor";
6464
import type { Variable } from "project-editor/features/variable/variable";
6565
import type {
6666
OutputActionComponent,
67-
CallActionActionComponent
67+
CallActionActionComponent,
68+
CommentActionComponent
6869
} from "project-editor/flow/components/actions";
6970
import type {
7071
ContainerWidget,
@@ -123,6 +124,7 @@ export interface IProjectEditor {
123124
ActionClass: typeof Action;
124125
ComponentClass: typeof Component;
125126
ActionComponentClass: typeof ActionComponent;
127+
CommentActionComponentClass: typeof CommentActionComponent;
126128
WidgetClass: typeof Widget;
127129
ConnectionLineClass: typeof ConnectionLine;
128130
UserWidgetWidgetClass: typeof UserWidgetWidget;

0 commit comments

Comments
 (0)