Skip to content

Commit 79abd8a

Browse files
authored
fix: registry tools is not available (#4799)
1 parent d3ec58e commit 79abd8a

File tree

4 files changed

+111
-84
lines changed

4 files changed

+111
-84
lines changed

src/registry/tool/anchor.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,18 @@ interface Options extends ToolItemOptions {
352352
) => Edge.TerminalCellData['anchor']
353353
}
354354

355-
export const SourceAnchor = Anchor.define<Options>({
356-
name: 'source-anchor',
357-
type: 'source',
358-
})
355+
export class SourceAnchor extends Anchor {
356+
public static defaults: Options = {
357+
...Anchor.getDefaults(),
358+
name: 'source-anchor',
359+
type: 'source',
360+
}
361+
}
359362

360-
export const TargetAnchor = Anchor.define<Options>({
361-
name: 'target-anchor',
362-
type: 'target',
363-
})
363+
export class TargetAnchor extends Anchor {
364+
public static defaults: Options = {
365+
...Anchor.getDefaults(),
366+
name: 'target-anchor',
367+
type: 'target',
368+
}
369+
}

src/registry/tool/arrowhead.ts

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -134,28 +134,34 @@ interface Options extends ToolItemOptions {
134134
ratio?: number
135135
}
136136

137-
export const SourceArrowhead = Arrowhead.define<Options>({
138-
name: 'source-arrowhead',
139-
type: 'source',
140-
ratio: 0,
141-
attrs: {
142-
d: 'M 10 -8 -10 0 10 8 Z',
143-
fill: '#333',
144-
stroke: '#fff',
145-
'stroke-width': 2,
146-
cursor: 'move',
147-
},
148-
})
149-
150-
export const TargetArrowhead = Arrowhead.define<Options>({
151-
name: 'target-arrowhead',
152-
type: 'target',
153-
ratio: 1,
154-
attrs: {
155-
d: 'M -10 -8 10 0 -10 8 Z',
156-
fill: '#333',
157-
stroke: '#fff',
158-
'stroke-width': 2,
159-
cursor: 'move',
160-
},
161-
})
137+
export class SourceArrowhead extends Arrowhead {
138+
public static defaults: Options = {
139+
...Arrowhead.getDefaults(),
140+
name: 'source-arrowhead',
141+
type: 'source',
142+
ratio: 0,
143+
attrs: {
144+
d: 'M 10 -8 -10 0 10 8 Z',
145+
fill: '#333',
146+
stroke: '#fff',
147+
'stroke-width': 2,
148+
cursor: 'move',
149+
},
150+
}
151+
}
152+
153+
export class TargetArrowhead extends Arrowhead {
154+
public static defaults: Options = {
155+
...Arrowhead.getDefaults(),
156+
name: 'target-arrowhead',
157+
type: 'target',
158+
ratio: 1,
159+
attrs: {
160+
d: 'M -10 -8 10 0 -10 8 Z',
161+
fill: '#333',
162+
stroke: '#fff',
163+
'stroke-width': 2,
164+
cursor: 'move',
165+
},
166+
}
167+
}

src/registry/tool/button.ts

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -148,35 +148,38 @@ interface Options extends ToolItemOptions {
148148
) => any
149149
}
150150

151-
export const Remove = Button.define<Options>({
152-
name: 'button-remove',
153-
markup: [
154-
{
155-
tagName: 'circle',
156-
selector: 'button',
157-
attrs: {
158-
r: 7,
159-
fill: '#FF1D00',
160-
cursor: 'pointer',
151+
export class Remove extends Button {
152+
public static defaults: Options = {
153+
...Button.getDefaults(),
154+
name: 'button-remove',
155+
markup: [
156+
{
157+
tagName: 'circle',
158+
selector: 'button',
159+
attrs: {
160+
r: 7,
161+
fill: '#FF1D00',
162+
cursor: 'pointer',
163+
},
161164
},
162-
},
163-
{
164-
tagName: 'path',
165-
selector: 'icon',
166-
attrs: {
167-
d: 'M -3 -3 3 3 M -3 3 3 -3',
168-
fill: 'none',
169-
stroke: '#FFFFFF',
170-
'stroke-width': 2,
171-
'pointer-events': 'none',
165+
{
166+
tagName: 'path',
167+
selector: 'icon',
168+
attrs: {
169+
d: 'M -3 -3 3 3 M -3 3 3 -3',
170+
fill: 'none',
171+
stroke: '#FFFFFF',
172+
'stroke-width': 2,
173+
'pointer-events': 'none',
174+
},
172175
},
176+
],
177+
distance: 60,
178+
offset: 0,
179+
useCellGeometry: true,
180+
onClick({ view, btn }) {
181+
btn.parent.remove()
182+
view.cell.remove({ ui: true, toolId: btn.cid })
173183
},
174-
],
175-
distance: 60,
176-
offset: 0,
177-
useCellGeometry: true,
178-
onClick({ view, btn }) {
179-
btn.parent.remove()
180-
view.cell.remove({ ui: true, toolId: btn.cid })
181-
},
182-
})
184+
}
185+
}

src/registry/tool/editor.ts

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -324,25 +324,37 @@ interface CellEditorOptions extends ToolItemOptions {
324324
| string
325325
}
326326

327-
export const NodeEditor = CellEditor.define<CellEditorOptions>({
328-
attrs: {
329-
fontSize: 14,
330-
fontFamily: 'Arial, helvetica, sans-serif',
331-
color: '#000',
332-
backgroundColor: '#fff',
333-
},
334-
getText: 'text/text',
335-
setText: 'text/text',
336-
})
337-
338-
export const EdgeEditor = CellEditor.define<CellEditorOptions>({
339-
attrs: {
340-
fontSize: 14,
341-
fontFamily: 'Arial, helvetica, sans-serif',
342-
color: '#000',
343-
backgroundColor: '#fff',
344-
},
345-
labelAddable: true,
346-
getText: 'label/text',
347-
setText: 'label/text',
348-
})
327+
export class NodeEditor extends CellEditor {
328+
public static defaults: CellEditorOptions = ObjectExt.merge(
329+
{},
330+
CellEditor.defaults,
331+
{
332+
attrs: {
333+
fontSize: 14,
334+
fontFamily: 'Arial, helvetica, sans-serif',
335+
color: '#000',
336+
backgroundColor: '#fff',
337+
},
338+
getText: 'text/text',
339+
setText: 'text/text',
340+
},
341+
)
342+
}
343+
344+
export class EdgeEditor extends CellEditor {
345+
public static defaults: CellEditorOptions = ObjectExt.merge(
346+
{},
347+
CellEditor.defaults,
348+
{
349+
attrs: {
350+
fontSize: 14,
351+
fontFamily: 'Arial, helvetica, sans-serif',
352+
color: '#000',
353+
backgroundColor: '#fff',
354+
},
355+
labelAddable: true,
356+
getText: 'label/text',
357+
setText: 'label/text',
358+
},
359+
)
360+
}

0 commit comments

Comments
 (0)