You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
以下是官网和自定义的文件
`
import { TextNode, TextNodeModel } from '@logicflow/core';
import {
getShapeStyleFuction,
getTextStyleFunction,
} from '../getShapeStyleUtil';
// 文本节点
class TextNewNode extends TextNode {}
class TextNewModel extends TextNodeModel {
getNodeStyle() {
const style = super.getNodeStyle();
const properties = this.getProperties();
return getShapeStyleFuction(style, properties);
}
getTextStyle() {
const style = super.getTextStyle();
const properties = this.getProperties();
if (properties.backgroundColor) {
style.backgroundStyle = {
fill: properties.backgroundColor,
};
}
return getTextStyleFunction(style, properties);
}
setAttributes() {
super.setAttributes();
if (!this.text.value) {
this.text.value = 'text';
}
}
}
export default {
type: 'pro-text',
view: TextNewNode,
model: TextNewModel,
};
`
`
import { GraphModel, HtmlNode, HtmlNodeModel, NodeConfig } from '@logicflow/core';
import {
getShapeStyleFuction,
getTextStyleFunction,
} from '../getShapeStyleUtil';
// import { JSX } from "preact";
import React from 'react';
import ReactDOM from 'react-dom';
import Text from './Text';
class BoxxModel extends HtmlNodeModel {
constructor(data: NodeConfig, graphModel: GraphModel) {
super(data, graphModel)
this.config = data
}
initNodeData(data: any) {
super.initNodeData(data);
this.resizable = true;
if (this.text.value === '') {
this.text.value = 'text'
}
}
getNodeStyle() {
const style = super.getNodeStyle();
const properties = this.getProperties();
console.log(this.isSelected)
// if (this.isSelected) {
// style.backgroundStyle = {
// fill: '#fff',
// };
// }
return getShapeStyleFuction(style, properties);
}
getTextStyle() {
const style = super.getTextStyle();
const properties = this.getProperties();
return getTextStyleFunction(style, properties);
}
setAttributes() {
const data = this.getProperties();
// this.text.editable = false;
// this.text.value = '';
const width = data?.width || 100;
const height = data?.height || 80;
this.width = width;
this.height = height;
const node = this.getData() as any;
const { x, y, text } = node;
this.text = {
...text,
x: x,
y: y,
};
}
}
class BoxxNode extends HtmlNode {
setHtml(rootEl: HTMLElement) {
const { properties, type, text } = this.props.model;
console.log(this);
ReactDOM.render(<Text properties={{ ...properties }} type={type} text={text} />, rootEl);
}
}
// eslint-disable-next-line import/no-anonymous-default-export
export default {
type: 'textUrl',
view: BoxxNode,
model: BoxxModel,
};
`
Beta Was this translation helpful? Give feedback.
All reactions