Compare commits

..

8 Commits

Author SHA1 Message Date
b7d0c0bd62 chore: 🔧 release x6-react-shape@1.6.6 2024-08-15 13:59:13 +08:00
753bc29dcc fix: react-shape this.selectors must valid (#4374)
Co-authored-by: 魄兵 <pobing.slb@alibaba-inc.com>
2024-08-14 09:54:49 +08:00
9f200a272d chore: 🔧 change publish script 2023-11-14 10:28:35 +08:00
556121d68d chore(release): 🚀 publish
- @antv/x6-react-shape@1.6.5
2023-11-14 10:19:20 +08:00
2a132a2c19 fix: 🐛 support multiple graph 2023-11-14 10:16:18 +08:00
6d37943855 chore(release): 🚀 publish
- @antv/x6@1.35.0
2023-09-25 18:00:00 +08:00
1ca2114005 fix: 🐛 add judge when call renderHTMLComponent 2023-09-25 17:52:31 +08:00
032cce51df fix: 🐛 stop listen event when transform removed 2023-09-25 17:30:43 +08:00
6 changed files with 24 additions and 13 deletions

View File

@ -27,7 +27,7 @@
"package:inherit": "yarn package-inherit update",
"prepare": "is-ci || husky install configs/husky-config",
"precommit": "yarn lint-staged && lerna run --concurrency 1 --stream precommit",
"publish:latest": "yarn build:dev && lerna publish --no-private --ignore-scripts"
"publish:latest": "lerna publish from-package --no-private --ignore-scripts --dist-tag v1"
},
"lint-staged": {
"**/*.{js,jsx,tsx,ts,less,md,json}": [

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-react-shape",
"version": "1.6.4",
"version": "1.6.6",
"description": "X6 shape for rendering react components.",
"main": "lib/index.js",
"module": "es/index.js",
@ -31,9 +31,8 @@
"build:watch:esm": "yarn build:esm --w",
"build:watch:cjs": "yarn build:cjs --w",
"build": "run-p build:cjs build:esm build:umd",
"prebuild": "run-s lint clean",
"prepare": "yarn build",
"precommit": "lint-staged"
"prebuild": "run-s clean",
"prepare": "yarn build"
},
"lint-staged": {
"src/**/*.ts": [

View File

@ -6,17 +6,24 @@ import { Portal } from './portal'
import { Wrap } from './wrap'
export class ReactShapeView extends NodeView<ReactShape> {
protected targetId() {
return `${this.graph.view.cid}:${this.cell.id}`
}
protected init() {
super.init()
this.cell.on('removed', () => {
Portal.disconnect(this.cell.id)
Portal.disconnect(this.targetId())
})
}
getComponentContainer() {
return this.cell.prop('useForeignObject') === false
? (this.selectors.content as SVGElement)
: (this.selectors.foContent as HTMLDivElement)
return (
this.selectors &&
(this.cell.prop('useForeignObject') === false
? (this.selectors.content as SVGElement)
: (this.selectors.foContent as HTMLDivElement))
)
}
confirmUpdate(flag: number) {
@ -42,7 +49,7 @@ export class ReactShapeView extends NodeView<ReactShape> {
const component = this.graph.hook.getReactComponent(node)
const elem = React.createElement(Wrap, { graph, node, component })
if (Portal.isActive()) {
Portal.connect(this.cell.id, ReactDOM.createPortal(elem, root))
Portal.connect(this.targetId(), ReactDOM.createPortal(elem, root))
} else {
ReactDOM.render(elem, root)
}
@ -58,7 +65,7 @@ export class ReactShapeView extends NodeView<ReactShape> {
}
unmount() {
Portal.disconnect(this.cell.id)
Portal.disconnect(this.targetId())
this.unmountReactComponent()
super.unmount()
return this

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6",
"version": "1.34.14",
"version": "1.35.0",
"description": "JavaScript diagramming library that uses SVG and HTML for rendering.",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -521,6 +521,11 @@ export class Transform extends Widget<Transform.Options> {
}
}
}
protected onRemove() {
this.stopListening()
super.onRemove()
}
}
export namespace Transform {

View File

@ -77,7 +77,7 @@ export namespace HTML {
}
protected renderHTMLComponent() {
const container = this.selectors.foContent
const container = this.selectors && this.selectors.foContent
if (container) {
const $wrap = this.$(container).empty()
const component = this.graph.hook.getHTMLComponent(this.cell)