leafer-ui icon indicating copy to clipboard operation
leafer-ui copied to clipboard

动态设置指定元素的编辑框样式

Open ZhaoYouLee opened this issue 5 months ago • 3 comments

Image

动态设置editConfig,样式未生效 试了下初始化设置单独元素的editConfig也未生效

ZhaoYouLee avatar Aug 01 '25 10:08 ZhaoYouLee

这个不是实时生效的配置,需要调用一下app.editor.updateEditTool(),或选中元素前设置

leaferjs avatar Aug 01 '25 13:08 leaferjs

Image选中元素前设置还是不生效

ZhaoYouLee avatar Aug 06 '25 09:08 ZhaoYouLee

// #图形编辑器 [选中的元素列表]
import { App, Rect } from 'leafer-ui'
import '@leafer-in/editor' // 导入图形编辑器插件
import '@leafer-in/viewport' // 导入视口插件 (可选)

const app = new App({
    view: window,
    editor: {}
})

app.tree.add(Rect.one({ editable: true, fill: '#FEB027', cornerRadius: [20, 0, 0, 20] ,editConfig:{stroke:"red"}}, 100, 100))
app.tree.add(Rect.one({ editable: true, fill: '#FFE04B', cornerRadius: [0, 20, 20, 0] ,editConfig:{stroke:"blue"}}, 300, 100))

app.editor.select(app.tree.children[0])

// 打印选中的元素列表: [Rect]
console.log(app.editor.list) 

我也是想通过editConfig 指定 不同的 rect 的 编辑框颜色不一样。

比如第一个设置的编辑框颜色为红色,第二个是蓝色。

  • 先选中第一个 编辑框显示的红色 是正确的
  • 鼠标再移动到第二个rect 上,编辑框hover样式是 红色的,应该显示成蓝色
  • 鼠标点击选中第二个rect 编辑框是蓝色的 正确。 如何实现鼠标hover时的样式 正确显示?

yunxifd avatar Aug 11 '25 08:08 yunxifd