mirror of
https://gitee.com/antv/g6.git
synced 2024-11-30 18:58:34 +08:00
feat: add register xml node to interface and stroy book
This commit is contained in:
parent
49139948fe
commit
b090a03c95
@ -12,6 +12,7 @@ import * as Algorithm from './algorithm';
|
||||
const registerNode = Shape.registerNode;
|
||||
const registerEdge = Shape.registerEdge;
|
||||
const registerCombo = Shape.registerCombo;
|
||||
const registerNodeByXML = Shape.registerNodeByXML;
|
||||
const registerBehavior = Behaviors.registerBehavior;
|
||||
const registerLayout = Layout.registerLayout;
|
||||
const Minimap = Plugins.Minimap;
|
||||
@ -57,6 +58,7 @@ export default {
|
||||
registerCombo: Shape.registerCombo,
|
||||
registerBehavior: Behaviors.registerBehavior,
|
||||
registerLayout: Layout.registerLayout,
|
||||
registerNodeByXML: Shape.registerNodeByXML,
|
||||
Layout,
|
||||
Global,
|
||||
Minimap: Plugins.Minimap,
|
||||
|
@ -239,6 +239,25 @@ export default class Shape {
|
||||
shapeFactory[shapeType] = shapeObj;
|
||||
return shapeObj;
|
||||
}
|
||||
|
||||
public static registerNodeByXML(
|
||||
shapeType: string,
|
||||
xml: (cfg: NodeConfig) => string | string,
|
||||
extendDefinition: ShapeOptions = {}
|
||||
) {
|
||||
const shapeFactory = Shape.Node;
|
||||
const autoNodeDefinition = createNodeFromXML(xml);
|
||||
const nodeDefinition = {
|
||||
...extendDefinition,
|
||||
...autoNodeDefinition,
|
||||
}
|
||||
|
||||
const shapeObj = Object.assign({}, ShapeFramework, nodeDefinition);
|
||||
shapeObj.type = shapeType;
|
||||
shapeObj.itemType = 'node';
|
||||
shapeFactory[shapeType] = shapeObj;
|
||||
return shapeObj;
|
||||
}
|
||||
}
|
||||
|
||||
// 注册 Node 的工厂方法
|
||||
|
Loading…
Reference in New Issue
Block a user