diff --git a/projects/f-examples/connections/auto-snap/auto-snap.component.html b/projects/f-examples/connections/auto-snap/auto-snap.component.html index ec656058..a6d7ac59 100644 --- a/projects/f-examples/connections/auto-snap/auto-snap.component.html +++ b/projects/f-examples/connections/auto-snap/auto-snap.component.html @@ -1,16 +1,28 @@ - - + + @for (connection of connections; track connection.inputId) { - } -
drag me
-
to me
+
+
+
+
+
+ I'm a node +
+
+
+
+
+
+ I'm a node +
diff --git a/projects/f-examples/connections/auto-snap/auto-snap.component.scss b/projects/f-examples/connections/auto-snap/auto-snap.component.scss index 9489ecd7..9fdc9aaa 100644 --- a/projects/f-examples/connections/auto-snap/auto-snap.component.scss +++ b/projects/f-examples/connections/auto-snap/auto-snap.component.scss @@ -8,6 +8,18 @@ @include flow-common.node; } +.f-node-input, .f-node-output { + &:not(.f-node) { + @include flow-common.connectors; + } +} + +.f-node-output { + &:not(.f-node) { + border-radius: 4px; + } +} + .toolbar { @include flow-common.toolbar; } diff --git a/projects/f-examples/connections/connection-text/connection-text.component.html b/projects/f-examples/connections/connection-text/connection-text.component.html new file mode 100644 index 00000000..0fd126cd --- /dev/null +++ b/projects/f-examples/connections/connection-text/connection-text.component.html @@ -0,0 +1,41 @@ + + + + +
+ I'm a node +
+
+ I'm a node +
+ + + +
+ I'm a node +
+
+ I'm a node +
+ + + +
+ I'm a node +
+
+ I'm a node +
+
+
+
+ + Text Offset + + @for (option of offsetOptions; track option) { + {{ option }} + } + + +
diff --git a/projects/f-examples/connections/connection-text/connection-text.component.scss b/projects/f-examples/connections/connection-text/connection-text.component.scss new file mode 100644 index 00000000..6c0bf936 --- /dev/null +++ b/projects/f-examples/connections/connection-text/connection-text.component.scss @@ -0,0 +1,13 @@ +@use "../../flow-common"; + +::ng-deep connection-text { + @include flow-common.connection; +} + +.f-node { + @include flow-common.node; +} + +.toolbar { + @include flow-common.toolbar; +} diff --git a/projects/f-examples/connections/connection-text/connection-text.component.ts b/projects/f-examples/connections/connection-text/connection-text.component.ts new file mode 100644 index 00000000..0760279a --- /dev/null +++ b/projects/f-examples/connections/connection-text/connection-text.component.ts @@ -0,0 +1,36 @@ +import { ChangeDetectionStrategy, Component, ViewChild } from '@angular/core'; +import { FCanvasComponent, FFlowModule } from '@foblex/flow'; +import { MatFormField, MatLabel } from '@angular/material/form-field'; +import { MatOption } from '@angular/material/core'; +import { MatSelect } from '@angular/material/select'; + +@Component({ + selector: 'connection-text', + styleUrls: [ + '../../_mdc-controls.scss', + './connection-text.component.scss' + ], + templateUrl: './connection-text.component.html', + changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [ + FFlowModule, + MatFormField, + MatLabel, + MatOption, + MatSelect + ] +}) +export class ConnectionTextComponent { + + protected offsetOptions: string[] = [ '10', '25%', '30', '50%', '75', '100%' ]; + + protected fTextStartOffset: string = '50%'; + + @ViewChild(FCanvasComponent, { static: true }) + protected fCanvas!: FCanvasComponent; + + protected onLoaded(): void { + this.fCanvas.resetScaleAndCenter(false); + } +} diff --git a/projects/f-examples/connectors/connectability-check/connectability-check.component.scss b/projects/f-examples/connectors/connectability-check/connectability-check.component.scss index e6d93c29..4648189b 100644 --- a/projects/f-examples/connectors/connectability-check/connectability-check.component.scss +++ b/projects/f-examples/connectors/connectability-check/connectability-check.component.scss @@ -15,6 +15,12 @@ } } +.f-node-output { + &:not(.f-node) { + border-radius: 4px; + } +} + .f-connections-dragging { .f-node-input { &:not(.f-node-input-can-be-connected-to) { diff --git a/projects/f-examples/connectors/limiting-connections/limiting-connections.component.scss b/projects/f-examples/connectors/limiting-connections/limiting-connections.component.scss index 89844325..422dbeac 100644 --- a/projects/f-examples/connectors/limiting-connections/limiting-connections.component.scss +++ b/projects/f-examples/connectors/limiting-connections/limiting-connections.component.scss @@ -23,6 +23,12 @@ } } +.f-node-output { + &:not(.f-node) { + border-radius: 4px; + } +} + .toolbar { @include flow-common.toolbar; } diff --git a/projects/f-flow/src/f-connection/common/f-connection-text/f-connection-text-path.directive.ts b/projects/f-flow/src/f-connection/common/f-connection-text/f-connection-text-path.directive.ts index 9fb9fccb..160aafb7 100644 --- a/projects/f-flow/src/f-connection/common/f-connection-text/f-connection-text-path.directive.ts +++ b/projects/f-flow/src/f-connection/common/f-connection-text/f-connection-text-path.directive.ts @@ -35,7 +35,6 @@ export class FConnectionTextPathDirective implements IHasHostElement, OnInit { } public ngOnInit(): void { - this.hostElement.setAttribute('startOffset', this.base.fTextStartOffset || '50%'); this.hostElement.setAttribute('text-anchor', `middle`); this.symbolWidth = this.getSymbolWidth(this.base.fText || ''); } @@ -44,6 +43,10 @@ export class FConnectionTextPathDirective implements IHasHostElement, OnInit { return this.hostElement.getBBox(); } + public redraw(): void { + this.hostElement.setAttribute('startOffset', this.base.fTextStartOffset || '50%'); + } + private getFontStyles(element: SVGTextPathElement): { fontSize: string, fontFamily: string } { const computedStyles = this.fBrowser.window.getComputedStyle(element); return { diff --git a/projects/f-flow/src/f-connection/common/f-connection-text/f-connection-text.component.ts b/projects/f-flow/src/f-connection/common/f-connection-text/f-connection-text.component.ts index 6456e2c5..847abdce 100644 --- a/projects/f-flow/src/f-connection/common/f-connection-text/f-connection-text.component.ts +++ b/projects/f-flow/src/f-connection/common/f-connection-text/f-connection-text.component.ts @@ -46,7 +46,7 @@ export class FConnectionTextComponent implements IConnectionText { } public redraw(line: ILine): void { - + this.textPathDirective.redraw(); const isTextReverse: boolean = FConnectionTextComponent.isTextReverse(line); const dyValue = this.calculateDy(this.textPathDirective.fontSize, isTextReverse); diff --git a/projects/f-flow/src/f-draggable/node-resize/node-resize-preparation/node-resize-preparation.execution.ts b/projects/f-flow/src/f-draggable/node-resize/node-resize-preparation/node-resize-preparation.execution.ts index 1738360b..5dd5af5c 100644 --- a/projects/f-flow/src/f-draggable/node-resize/node-resize-preparation/node-resize-preparation.execution.ts +++ b/projects/f-flow/src/f-draggable/node-resize/node-resize-preparation/node-resize-preparation.execution.ts @@ -40,11 +40,9 @@ export class NodeResizePreparationExecution implements IExecution` component inside the ``. This component handles temporary connection display and snapping to the nearest connector when the threshold is reached. ## Example diff --git a/public/markdown/examples/connection-text.md b/public/markdown/examples/connection-text.md new file mode 100644 index 00000000..eeb41d03 --- /dev/null +++ b/public/markdown/examples/connection-text.md @@ -0,0 +1,19 @@ +# Connection Text + +## Description + +This guide demonstrates how to add text to connections in Foblex Flow for Angular. To add text to a connection, you need to set the `fText` property of the connection component. The text will be displayed in the middle of the connection line. Also, you can set `fTextStartOffset` parameter to adjust the text position along the connection line. +You can customize the text appearance using css styles. + +## Example + +::: ng-component [height]="600" +[component.html] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/connections/connection-text/connection-text.component.html +[component.ts] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/connections/connection-text/connection-text.component.ts +[component.scss] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/connections/connection-text/connection-text.component.scss +[common.scss] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/_flow-common.scss +::: + + + + diff --git a/public/markdown/examples/environment.ts b/public/markdown/examples/environment.ts index 2a91cf92..0c3205b9 100644 --- a/public/markdown/examples/environment.ts +++ b/public/markdown/examples/environment.ts @@ -133,6 +133,10 @@ function createEnvironment(): IDocsEnvironment { tag: 'connection-markers', component: import('../../../projects/f-examples/connections/connection-markers/connection-markers.component') }, + { + tag: 'connection-text', + component: import('../../../projects/f-examples/connections/connection-text/connection-text.component') + }, { tag: 'custom-connections', component: import('../../../projects/f-examples/connections/custom-connections/custom-connections.component') @@ -462,20 +466,14 @@ function connectionGroup(): INavigationGroup { description: 'Automatically snap connections to nodes in Foblex Flow, enabling easier diagram creation in Angular.', image: './previews/examples/auto-snap.light.png', image_dark: './previews/examples/auto-snap.dark.png', - image_width: 791, + image_width: 781, image_height: 600, image_type: 'image/png', + badge: { + text: 'Updated', + type: 'warning' + } }, - // { - // link: 'connection-selection', - // text: 'Connection Selection', - // description: 'Select connections in Foblex Flow diagrams for Angular.', - // image: './previews/examples/connection-selection.light.png', - // image_dark: './previews/examples/connection-selection.dark.png', - // image_width: 806, - // image_height: 600, - // image_type: 'image/png', - // }, { link: 'connection-types', text: 'Connection Types', @@ -516,6 +514,20 @@ function connectionGroup(): INavigationGroup { image_height: 600, image_type: 'image/png', }, + { + link: 'connection-text', + text: 'Connection Text', + description: 'Add text to connections in Foblex Flow diagrams for Angular.', + image: './previews/examples/connection-text.light.png', + image_dark: './previews/examples/connection-text.dark.png', + image_width: 781, + image_height: 600, + image_type: 'image/png', + badge: { + text: 'New', + type: 'info' + } + }, { link: 'custom-connections', text: 'Custom Connections', @@ -526,14 +538,6 @@ function connectionGroup(): INavigationGroup { image_height: 600, image_type: 'image/png', }, - // { - // link: 'connection-text', - // text: 'Connection Text', - // }, - // { - // link: 'connection-center', - // text: 'Connection Center', - // }, ] } } diff --git a/public/markdown/examples/node-selection.md b/public/markdown/examples/node-selection.md index f119b0d1..94f99020 100644 --- a/public/markdown/examples/node-selection.md +++ b/public/markdown/examples/node-selection.md @@ -2,7 +2,7 @@ ## Description -This guide demonstrates how to select nodes in Foblex Flow for Angular. Use a `mouse click` to select a single node, or hold the `SHIFT` or `CTRL/CMD` key `while clicking` to select multiple nodes. +This guide demonstrates how to select nodes in Foblex Flow for Angular. Use a `mouse click` to select a single node, or hold the `CTRL/CMD` key `while clicking` to select multiple nodes. ## Example ::: ng-component [height]="600" diff --git a/public/previews/examples/auto-snap.dark.png b/public/previews/examples/auto-snap.dark.png index 0968652a..586b57bc 100644 Binary files a/public/previews/examples/auto-snap.dark.png and b/public/previews/examples/auto-snap.dark.png differ diff --git a/public/previews/examples/auto-snap.light.png b/public/previews/examples/auto-snap.light.png index 2f94280e..2ee81373 100644 Binary files a/public/previews/examples/auto-snap.light.png and b/public/previews/examples/auto-snap.light.png differ diff --git a/public/previews/examples/connection-text.dark.png b/public/previews/examples/connection-text.dark.png new file mode 100644 index 00000000..4e80ed1a Binary files /dev/null and b/public/previews/examples/connection-text.dark.png differ diff --git a/public/previews/examples/connection-text.light.png b/public/previews/examples/connection-text.light.png new file mode 100644 index 00000000..b50deb46 Binary files /dev/null and b/public/previews/examples/connection-text.light.png differ