自定义资产管理器。如何设置背景图片
问题
你好! 我正在为资产管理器构建一个自定义模态,基本上,我似乎需要覆盖“open-assets”“”命令。 我如何理解用户是否想设置图片src或背景图片属性? 提前感谢大家!
回答(4)
赞同,我刚开始用GrapeJS,并让它在我的系统上运行起来,想在头部div上设置背景图片,而不用写CSS代码 :/
实际上,关于资产选择的知识不应该包含在指挥系统本身,因为行动应由谁来执行命令来决定,例如: “''js editor.runCommand('open-assets', { onSelect(asset) { const cmp = editor.getSelected(); cmp && cmp.addStyle({ 'background-image': 'url(“${asset.get('src')}”)' }) } }); ``` 我建议你检查一下当前的[命令](https://github.com/artf/grapesjs/blob/dev/src/commands/view/...
这并不是我们问题的正确解决方案。
我想做的是把这个功能添加到一个组件里,我们该怎么做?
谢谢你举报,@mmotov。 关于自定义资产管理工具'的好问题。如何设置背景图片。GrapesJS 推荐的方法是使用事件驱动 API。 从这里开始: 查看你所在模块的[GrapesJS文档](https://grapesjs.com/docs/) 寻找“on()”事件监听器方法 大多数操作可以通过监听编辑器和组件事件来实现 常见模式: “JavaScript 留意变化 editor.on('change', () => console.log('something changed')); 组件生命周期 editor.on('component:mount', (c) => console.l...
相关问答
通过相似的问题讨论继续研究。
问题 #3367
模态模板
有没有办法修改已编译状态的模板? https://github.com/artf/grapesjs/blob/d3256e621bb43a537213ffcd86b10dc0bd070c0b/src/modal_dialog/view/ModalView.js#L1-L16 如...
问题 #6655
我在正确换色时遇到了colopicker的卡顿问题
https://github.com/GrapesJS/grapesjs/blob/f59e981f76ff378f59c06cf706af88e502db098e/packages/core/src/utils/ColorPicker.ts#L2407C5-L2415C6 我...
问题 #3315
毫米或厘米单位转换为px。
我意识到毫米或厘米单位是可以转换成像素的。我该如何解决这个问题? 谢谢你 ' 然后再用事件。 有没有办法获取json对象(比如编辑器里调用函数或者某个属性)? 或者有没有办法停止“editor.stor...
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
相关教程
关于同一主题的深入指南。
教程
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.
浏览插件分类
直接跳转到市场上的插件分类页面。