如何从 StyleManager 获取更改后的属性
问题
你好,
有没有办法知道StyleManager里更改了哪个属性?比如说,如果我选择一个文本组件并从 StyleManager 更改其背景色属性,有没有什么事件可以让我获得被更改的属性? 我尝试过“component:styleUpdate”事件,但它传递的是组件模型的参数,而不是属性。
任何帮助都非常感谢。
回答(3)
@AbdiasM我觉得这有点像骨干相关的事情,据我所知目前还不可能。这才是应该的样子:
editor.on('component:styleUpdate', component => {
console.log(Object.keys(component.changedAttributes())
})
干杯!
实际上,你会得到更改属性作为回调的第二个参数 “''js editor.on('component:styleUpdate', (component, propChanged) => { ... })
你好@AbdiasM基于[component:styleUpdate](https://grapesjs.com/docs/api/editor.html#available-events)或[component:styleUpdate:{propertyName}](https://grapesjs.com/docs/api/editor.html#available-events),你可以获得如下的属性: 干杯!
相关问答
通过相似的问题讨论继续研究。
问题 #4897
Component:styleUpdate / component:styleUpdate:propertyName 未被触发
葡萄JS版本 [X] 我确认使用最新版本的GrapesJS 你用的是什么浏览器? Edge 109.0.1518.70 可复制演示链接 https://jsfiddle.net/rudacs/kr2x1mnh/ 描述一下那个虫子 如何复现这个漏洞?在 StyleManager...
问题 #1708
StyleManager 事件每次变更都会多次触发
复制: 在全新安装的GrapesJS中,在演示页面(index.html内)添加一个事件监听器,如下: 'editor.on('component:styleUpdate:width', (model) => { console.log(模型); });问题: 当更改任何元素的...
问题 #1904
找零财产浮动
我正在尝试通过事件监听“float”属性的变化,判断它是在Style Manager中被移到了“左”、“右”还是“无”,但我的代码似乎没有给出想要的结果。 它给出的是“style update null”作为输出。理想的输出是float:right、float:left或flo...
问题 #3137
当我选择某个特定元素时,我没有看到它的样式。这个问题只发生在某些元素上。
未获得所选元素的样式 这是我的代码, const model = 编辑器。StyleManager.getModelToStyle(component); let styleObject = model.getStyle(); console.log(“样式”,styleObj...
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
浏览插件分类
直接跳转到市场上的插件分类页面。