未选中的自定义组件也会监听事件“styleable:change”
你好@iamqinglong这是你在编辑器模型上创建监听器时预期的行为,但你可以通过这种方式检查所选组件 “''js init() { const component = this.model; this.listenTo(this.em, 'styleable:change', (args, property) => { if (editor.getSelected() === component) { console.log(args,财产); } }); } ```
阅读下方完整回答 ↓问题
葡萄JS版本 [X] 我确认使用最新版本的GrapesJS 你用的是什么浏览器? 铬100 可复制演示链接 https://grapesjs.com/demo.html 描述一下那个虫子 如何复现这个漏洞?删除两个或多个自定义组件 <img width=“1230” alt=“截图 2022-06-10 下午3 11 54” src=“https://user-images.githubusercontent.com/48402616/173286267-09325ccd-6475-4b81-84ca-790a3f1b168b.png”>重新设计任一组件另一个未被选中的组件也会监听 'styleable:change' 事件 <img width=“1438” alt=“截图 2022-06-10 3 10 29 PM” src=“https://user-images.githubusercontent.com/48402616/173286325-4bd75e2e-21ef-4e3b-9d83-a78aea0674b0.png”> 预期的行为是什么? 未被选中的组件不应响应所选组件的“styleable:change”事件 目前的行为是什么? 未被选中的组件监听所选组件的“styleable:change”事件 如果需要执行某些代码以重现该漏洞,请将其粘贴到下面: “''js...
回答(2)
你好@iamqinglong这是你在编辑器模型上创建监听器时预期的行为,但你可以通过这种方式检查所选组件 “''js init() { const component = this.model; this.listenTo(this.em, 'styleable:change', (args, property) => { if (editor.getSelected() === component) { console.log(args,财产); } }); }
谢谢你举报,@iamqinglong。 关于未被选中的自定义组件也会监听事件'styleable:change'的好问题。推荐的 StyleManager 方法是使用事件驱动的 API。 从这里开始: 查看你所在模块的[GrapesJS文档](https://grapesjs.com/docs/) 寻找“on()”事件监听器方法 大多数操作可以通过监听编辑器和组件事件来实现 常见模式: “JavaScript 留意变化 editor.on('change', () => console.log('something changed')); 组件生命周期 editor.on('componen...
相关问答
通过相似的问题讨论继续研究。
问题 #5346
删除组件而不删除其对应样式
葡萄JS版本 [X] 我确认使用最新版本的GrapesJS 你用的是什么浏览器? 最新版本的Chrome浏览器 可复制演示链接 https://grapesjs.com/demo.html 描述一下那个虫子 如何复现这个漏洞? <img width=“1665” alt=“im...
问题 #3397
分拣器方向与网页组件槽不符
版本:0.16.45 你能重现演示中的这个bug吗?[x] 是的[ ] 不 预期的行为是什么? 给定一个父网页组件实例渲染一些元素,在 shadowDOM 中,如果 'slot' 的父元素具有 'display: flex' 风格,排序器应是垂直的,因为结果中元素是水平对齐的。...
问题 #4257
背景修改对非图像无效
葡萄JS版本 [X] 我确认使用最新版本的GrapesJS 你用的是什么浏览器? Chrome v100 可复制演示链接 https://grapesjs.com/demo.html 描述一下那个虫子 如何复现这个漏洞?点击任意组件,在样式管理器中滚动到装饰>背景尝试制作一个带...
问题 #5263
如果删除组件但不删除其对应样式,之后添加新组件会导致样式冲突吗?
葡萄JS版本 [X] 我确认使用最新版本的GrapesJS 你用的是什么浏览器? 最新版本的Chrome浏览器 可复制演示链接 无效 描述一下那个虫子 如何复现这个漏洞? <img width=“1666” alt=“image” src=“https://github.com...
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
相关教程
关于同一主题的深入指南。
教程
GrapesJS DevTools: A Developer Panel Inside Your Editor
If you've ever debugged GrapesJS with console.log(editor.getSelected()) and a dozen throwaway event listeners — this post is for you.
教程
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
教程
Big Updates: TinyMCE 8 and Placeholder 2.0 for GrapesJS
In May we shipped major updates to two of our most popular GrapesJS plugins — TinyMCE Inline Text Editor and Placeholder.
浏览插件分类
直接跳转到市场上的插件分类页面。