Skip to content

Commit

Permalink
feat: node-editor新增width和height配置 (#3827)
Browse files Browse the repository at this point in the history
Co-authored-by: aflextyang <[email protected]>
  • Loading branch information
aflext and aflextyang authored Aug 7, 2023
1 parent d9167a2 commit 9cc7737
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/x6/src/registry/tool/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export class CellEditor extends ToolsView.ToolItem<
let minWidth = 20
let translate = ''
let { x, y } = this.options
const { width, height } = this.options

if (typeof x !== 'undefined' && typeof y !== 'undefined') {
const bbox = cell.getBBox()
Expand All @@ -105,6 +106,13 @@ export class CellEditor extends ToolsView.ToolItem<
style.top = `${pos.y}px`
style.transform = `scale(${scale.sx}, ${scale.sy}) ${translate}`
style.minWidth = `${minWidth}px`

if (typeof width === 'number') {
style.width = `${width}px`
}
if (typeof height === 'number') {
style.height = `${height}px`
}
}

updateEdgeEditorTransform() {
Expand Down Expand Up @@ -270,6 +278,8 @@ export namespace CellEditor {
export interface CellEditorOptions extends ToolsView.ToolItem.Options {
x?: number | string
y?: number | string
width?: number
height?: number
attrs: {
fontSize: number
fontFamily: string
Expand Down

0 comments on commit 9cc7737

Please sign in to comment.