@logicflow/core
Version:
LogicFlow, help you quickly create flowcharts
68 lines (67 loc) • 3 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);
};
import { cloneDeep } from 'lodash-es';
import BaseNodeModel from './BaseNodeModel';
import { ModelType } from '../../constant';
var HtmlNodeModel = /** @class */ (function (_super) {
__extends(HtmlNodeModel, _super);
// @observable properties: IHtmlNodeProperties = {}
function HtmlNodeModel(data, graphModel) {
var _this = _super.call(this, data, graphModel) || this;
_this.modelType = ModelType.HTML_NODE;
// this.properties = data.properties || {}
_this.setAttributes();
return _this;
}
HtmlNodeModel.prototype.setAttributes = function () {
_super.prototype.setAttributes.call(this);
var _a = this.properties, width = _a.width, height = _a.height;
if (width)
this.width = width;
if (height)
this.height = height;
};
HtmlNodeModel.prototype.getDefaultAnchor = function () {
var _a = this, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
return [
{ x: x, y: y - height / 2, id: "".concat(this.id, "_0") },
{ x: x + width / 2, y: y, id: "".concat(this.id, "_1") },
{ x: x, y: y + height / 2, id: "".concat(this.id, "_2") },
{ x: x - width / 2, y: y, id: "".concat(this.id, "_3") },
];
};
HtmlNodeModel.prototype.getNodeStyle = function () {
var style = _super.prototype.getNodeStyle.call(this);
var _a = this.graphModel.theme, baseNode = _a.baseNode, html = _a.html;
var _b = this.properties.style, customStyle = _b === void 0 ? {} : _b;
var finalStyle = __assign(__assign(__assign(__assign({}, style), cloneDeep(baseNode)), cloneDeep(html)), cloneDeep(customStyle));
return finalStyle;
};
return HtmlNodeModel;
}(BaseNodeModel));
export { HtmlNodeModel };
export default HtmlNodeModel;