@logicflow/extension
Version:
LogicFlow Extensions
95 lines (94 loc) • 3.9 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@logicflow/core");
var MarkRootModel = /** @class */ (function (_super) {
__extends(MarkRootModel, _super);
function MarkRootModel(data, graphModel) {
if (!data.text) {
data.text = {
x: data.x,
y: data.y + 15,
value: '',
};
}
return _super.call(this, data, graphModel) || this;
}
MarkRootModel.prototype.setAttributes = function () {
this.height = 60;
this.strokeWidth = 1;
this.stroke = '#646764';
};
MarkRootModel.extendKey = 'MarkRootModel';
return MarkRootModel;
}(core_1.RectNodeModel));
var MarkRootView = /** @class */ (function (_super) {
__extends(MarkRootView, _super);
function MarkRootView() {
return _super !== null && _super.apply(this, arguments) || this;
}
MarkRootView.prototype.getLabelShape = function () {
var _a = this.props.model, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
var style = this.props.model.getNodeStyle();
return (0, core_1.h)('svg', {
x: x - width / 2 + 5,
y: y - height / 2 + 5,
width: 25,
height: 25,
viewBox: '0 0 1274 1024',
}, (0, core_1.h)('path', {
fill: style.stroke,
d: 'M655.807326 287.35973m-223.989415 0a218.879 218.879 0 1 0 447.978829 0 218.879 218.879 0 1 0-447.978829 0ZM1039.955839 895.482975c-0.490184-212.177424-172.287821-384.030443-384.148513-384.030443-211.862739 0-383.660376 171.85302-384.15056 384.030443L1039.955839 895.482975z',
}));
};
MarkRootView.prototype.getShape = function () {
var style = this.props.model.getNodeStyle();
var _a = this.props.model, x = _a.x, y = _a.y, width = _a.width, height = _a.height, radius = _a.radius;
// todo: 将basic-shape对外暴露,在这里可以直接用。现在纯手写有点麻烦。
return (0, core_1.h)('g', {}, [
(0, core_1.h)('rect', __assign({ x: x - width / 2, y: y - height / 2, rx: radius, ry: radius, width: width, height: height }, style)),
this.getLabelShape(),
(0, core_1.h)('text', {
fill: style.stroke,
fontSize: 12,
x: x - width / 2 + 30,
y: y - height / 2 + 20,
width: 50,
height: 25,
}, '中心主题'),
]);
};
MarkRootView.extendKey = 'MarkRoot';
return MarkRootView;
}(core_1.RectNode));
var MarkRoot = {
type: 'mark:root',
view: MarkRootView,
model: MarkRootModel,
};
exports.default = MarkRoot;
;