Skip to content

Commit

Permalink
fix: support cancel editor no mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
NewByVector committed Oct 12, 2023
1 parent f99f0c0 commit 1d532ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/x6/src/registry/router/manhattan/obstacle-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class ObstacleMap {
const excluded =
excludedShape || excludedTerminal || excludedNode || excludedAncestor

if (!excluded) {
if (node.isVisible() && !excluded) {
const bbox = node.getBBox().moveAndExpand(options.paddingBox)
const origin = bbox.getOrigin().snapToGrid(mapGridSize)
const corner = bbox.getCorner().snapToGrid(mapGridSize)
Expand Down
23 changes: 14 additions & 9 deletions packages/x6/src/registry/tool/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class CellEditor extends ToolsView.ToolItem<
style.transform = `scale(${scale.sx}, ${scale.sy}) translate(-50%, -50%)`
}

onDocumentMouseDown(e: Dom.MouseDownEvent) {
onDocumentMouseUp(e: Dom.MouseDownEvent) {
if (this.editor && e.target !== this.editor) {
const value = this.editor.innerText.replace(/\n$/, '') || ''
// set value, when value is null, we will remove label in edge
Expand All @@ -171,13 +171,15 @@ export class CellEditor extends ToolsView.ToolItem<
}

onCellDblClick({ e }: { e: Dom.DoubleClickEvent }) {
e.stopPropagation()
this.removeElement()
this.event = e
this.createElement()
this.updateEditor()
this.autoFocus()
this.delegateDocumentEvents(this.options.documentEvents!)
if (!this.editor) {
e.stopPropagation()
this.removeElement()
this.event = e
this.createElement()
this.updateEditor()
this.autoFocus()
this.delegateDocumentEvents(this.options.documentEvents!)
}
}

onMouseDown(e: Dom.MouseDownEvent) {
Expand Down Expand Up @@ -316,9 +318,12 @@ export namespace CellEditor {
isSVGElement: false,
events: {
mousedown: 'onMouseDown',
touchstart: 'onMouseDown',
},
documentEvents: {
mousedown: 'onDocumentMouseDown',
mouseup: 'onDocumentMouseUp',
touchend: 'onDocumentMouseUp',
touchcancel: 'onDocumentMouseUp',
},
})
}
Expand Down

0 comments on commit 1d532ea

Please sign in to comment.