Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复设置 textDraggable 为 true 时,边、节点文本无法拖拽的 bug #2003

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/feature-examples/src/pages/graph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const config: Partial<LogicFlow.Options> = {
isSilentMode: false,
stopScrollGraph: true,
stopZoomGraph: true,
// textDraggable: true, // TODO: 节点旋转状态下,拖动文本移动是有问题的!!!
edgeTextDraggable: true,
style: {
rect: {
rx: 5,
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/model/edge/BaseEdgeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,14 +515,17 @@ export class BaseEdgeModel<P extends PropertiesType = PropertiesType>
* 内部方法,处理初始化文本格式
*/
@action formatText(data: EdgeConfig) {
const {
editConfigModel: { edgeTextDraggable, edgeTextEdit },
} = this.graphModel
const { x, y } = this.textPosition
const { text } = data
let textConfig: Required<TextConfig> = {
value: '',
x,
y,
draggable: false,
editable: true,
draggable: edgeTextDraggable,
editable: edgeTextEdit,
}

if (text) {
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/model/node/BaseNodeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,16 @@ export class BaseNodeModel<P extends PropertiesType = PropertiesType>
* 始化文本属性
*/
private formatText(data: NodeConfig): void {
const {
editConfigModel: { nodeTextDraggable, nodeTextEdit },
} = this.graphModel
const { x, y, text } = data
let textConfig: TextConfig = {
value: '',
x,
y,
draggable: false,
editable: true,
draggable: nodeTextDraggable,
editable: nodeTextEdit,
}
if (text) {
if (typeof text === 'string') {
Expand Down