Skip to content

Commit

Permalink
fix: render react shape in dnd graph (#2970)
Browse files Browse the repository at this point in the history
  • Loading branch information
NewByVector authored Nov 29, 2022
1 parent 94f9042 commit 6a81805
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/x6-plugin-snapline/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import './api'

export class Snapline extends Disposable {
private snaplineImpl: SnaplineImpl
public options: Snapline.Options
public name = 'snapline'

constructor(public readonly options: Snapline.Options) {
constructor(options: Snapline.Options) {
super()
this.options = { tolerance: 10, ...options }
CssLoader.ensure(this.name, content)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/x6-plugin-snapline/src/snapline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class SnaplineImpl extends View implements IDisablable {

const { graph, ...others } = options
this.graph = graph
this.options = { tolerance: 10, ...others }
this.options = { ...others }
this.offset = { x: 0, y: 0 }
this.render()
if (!this.disabled) {
Expand Down
5 changes: 4 additions & 1 deletion packages/x6-react-shape/src/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export class ReactShapeView extends NodeView<ReactShape> {
const node = this.cell

if (container) {
const elem = React.createElement(Wrap, { node, graph: node.model!.graph })
const graph = node.model ? node.model.graph : null
// Actually in the dnd plugin, this graph is empty,
// in order to make the external perception type of graph is a graph, rather than graph | null, so hack this.
const elem = React.createElement(Wrap, { node, graph: graph! })
if (Portal.isActive()) {
const portal = createPortal(elem, container) as ReactPortal
Portal.connect(this.cell.id, portal)
Expand Down
3 changes: 2 additions & 1 deletion packages/x6/src/renderer/queueJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export class JobQueue {
try {
job.cb()
} catch (error) {
// pass
// eslint-disable-next-line
console.log(error)
}
}

Expand Down

0 comments on commit 6a81805

Please sign in to comment.