Skip to content

Commit

Permalink
fix(extension): 修复 BpmnAdapter 导入含有边的 xml 报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
fanyang committed Aug 26, 2024
1 parent b7a5143 commit e25abac
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@

.upload {
position: absolute;
top: 0;
left: 0;
z-index: 99;
display: block;
width: 24px;
cursor: pointer;
opacity: 0;
}
Expand Down
17 changes: 7 additions & 10 deletions examples/feature-examples/src/pages/extensions/bpmn/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ export default function BPMNExtension() {
if (!lf) {
return
}
lf.renderByXml(xml)

lf.render(xml)
}

useEffect(() => {
Expand All @@ -158,7 +159,7 @@ export default function BPMNExtension() {
...config,
container: containerRef.current as HTMLElement,
})

lfRef.current = lf
lf.setMenuConfig(menuConfig)

const commonMenuConfig = {
Expand Down Expand Up @@ -207,8 +208,7 @@ export default function BPMNExtension() {

const sessionStorageData = window.sessionStorage.getItem('lf-data')
if (sessionStorageData) {
lfData = JSON.parse(sessionStorageData)
renderXml(lfData)
renderXml(sessionStorageData)
} else {
const lfJsonData = window.sessionStorage.getItem('lf-json-data')
if (!lfJsonData) {
Expand All @@ -225,16 +225,13 @@ export default function BPMNExtension() {
if (pathes) {
lf.setRawPathes(JSON.parse(pathes))
}

lfRef.current = lf
}
}, [])

const handleDownloadData = () => {
const data = lfRef.current?.getGraphData()
const dataString = JSON.stringify(data)
download('logicflow.xml', dataString)
window.sessionStorage.setItem('lf-data', dataString)
const data = lfRef.current?.getGraphData() as string
download('logicflow.xml', data)
window.sessionStorage.setItem('lf-data', data)
}

const handleUploadData = (e: React.ChangeEvent<HTMLInputElement>) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/bpmn-adapter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ function getLfEdges(value, bpmnEdges) {

function getEdgeConfig(edgeValue, processValue): EdgeConfig {
let text
const textVal = `${processValue['-name']}`
const textVal = processValue['-name'] ? `${processValue['-name']}` : ''
if (textVal) {
const textBounds = edgeValue['bpmndi:BPMNLabel']['dc:Bounds']
// 如果边文本换行,则其偏移量应该是最长一行的位置
Expand Down

0 comments on commit e25abac

Please sign in to comment.