问题:图层标签
问题
@artf我很喜欢和GJS合作。我还有最后一件事希望你能帮忙。
如果能在图层管理器中自定义标签会非常有帮助。我到处找过,但都没找到。
默认显示“文本”和“框”的方式,对于想要高效导航来说帮助不大。
<img width=“204” alt=“截图 2021-01-28 07 27 16” src=“https://user-images.githubusercontent.com/2796719/106104795-d5544800-613a-11eb-97c4-762e5977e872.png”>
我真的很想自己定制这些。就我而言,我想展示标签名和身份识别码。
非常感谢
回答(4)
你可以扩展组件模型并覆盖“getName”函数
如果这对任何人有用,我找到了一个简单且替代的方法,可以在组件创建时实现这一点。
我是这样做的:
grapesInstance.on('component:create', (component) => {
component.getName = () => component.attributes['custom-name'] ||'${component.attributes.tagName}#${component.ccid}';
});
好处是如果组件ID或标签以后更改,图层管理器里仍会更新,而且你也可以重新命名单个组件。
谢谢你举报,@fmay。 关于问题:图层标签的好问题。GrapesJS 推荐的方法是使用事件驱动 API。 从这里开始: 查看你所在模块的[GrapesJS文档](https://grapesjs.com/docs/) 寻找“on()”事件监听器方法 大多数操作可以通过监听编辑器和组件事件来实现 常见模式: “JavaScript 留意变化 editor.on('change', () => console.log('something changed')); 组件生命周期 editor.on('component:mount', (c) => console.log('component...
相关问答
通过相似的问题讨论继续研究。
问题 #4608
从0.19.4升级到最新0.20.1后,图层管理器下的图标不再可见。
葡萄JS版本 [X] 我确认使用最新版本的GrapesJS 你用的是什么浏览器? 版本 104.0.5112.101(官方构建)(arm64) 可复制演示链接 截图:https://d.pr/i/AyHJyL 描述一下那个虫子 如何复现这个漏洞?升级到最新的葡萄品种。 预期的行...
问题 #4646
偶数/奇数状态没有按预期工作
葡萄JS版本 [X] 我确认使用最新版本的GrapesJS 你用的是什么浏览器? 106.0.5249.91 可复制演示链接 https://grapesjs.com/demo.html 描述一下那个虫子 如何复现这个漏洞?拖拽“1列”方块在列中添加四个“文本”块选择列并选择“...
问题 #3623
“/”在类别中变为“-”
版本: ^0.17.19 你能重现演示中的bug吗?[x] 是的[ ] 不 预期的行为是什么? 我预计这门课会保持我命名的那个。 详细描述那个漏洞* 当你在DOM中添加一个包含斜杠“/”字符的职业时,该斜杠字符会变成破折号“-”。 详细描述那个漏洞 <img width=“38...
问题 #3154
在打开图层管理器中点击眼睛图标时隐藏元素
我想看到代码处理事件隐藏或删除元素。我在哪里能找到它? <img width=“958” alt=“Capture” src=“https://user-images.githubusercontent.com/56115755/99949266-509d2480-2dad-1...
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
相关教程
关于同一主题的深入指南。
教程
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.
浏览插件分类
直接跳转到市场上的插件分类页面。