关于StorageManager存储的JSON的问题
@theSC0RP 这是你在找的吗?[editor.getComponents()](https://grapesjs.com/docs/api/editor.html#getcomponents)
阅读下方完整回答 ↓问题
嘿,@artf。我想访问在存储模板时生成的 json,但不想实际存储模板。json 对象可以通过事件访问,但我不想调用 'editor.store()' 然后再用事件。 有没有办法获取json对象(比如编辑器里调用函数或者某个属性)? 或者有没有办法停止“editor.store()”方法,这样我就能获取正在存储的json并中止调用?
回答(4)
@theSC0RP 这是你在找的吗?[editor.getComponents()](https://grapesjs.com/docs/api/editor.html#getcomponents)
@theSC0RP不确定你是否想要存储功能,但Josh提出的方案是正确的,或者你也可以添加存储(如果需要,也可以在里面不做任何操作......)https://grapesjs.com/docs/modules/Storage.html#define-new-storage
你总可以添加存储(如果需要,也可以在里面什么都不做......)https://grapesjs.com/docs/modules/Storage.html#define-new-storage
谢谢@artf。这就是我最终做的。用 'editor.getComponents()' 时,你会得到一个循环结构(model -> view -> model -> ...),但 storageManager 不会存储它,也不能用来加载模板。
谢谢你举报,@theSC0RP。 关于关于存储管理器存储的JSON问题,这个问题非常棒。GrapesJS 推荐的方法是使用事件驱动 API。 从这里开始: 查看你所在模块的[GrapesJS文档](https://grapesjs.com/docs/) 寻找“on()”事件监听器方法 大多数操作可以通过监听编辑器和组件事件来实现 常见模式: “JavaScript 留意变化 editor.on('change', () => console.log('something changed')); 组件生命周期 editor.on('component:mount', (c) => consol...
相关问答
通过相似的问题讨论继续研究。
问题 #3237
添加特征 包装
你好@artf 我就是这样加了包裹特性。 我该如何执行初始化函数 这是代码 “''js editor.getWrapper().set('traits', [ { 变革提案:1, 名称:“ABC”, 标签:“ABC”, 类型:“勾选框”, 变革提案:1 }, ], ) ```...
问题 #3367
模态模板
有没有办法修改已编译状态的模板? https://github.com/artf/grapesjs/blob/d3256e621bb43a537213ffcd86b10dc0bd070c0b/src/modal_dialog/view/ModalView.js#L1-L16 如...
问题 #3142
AssetManager 渲染问题
@artf这正是之前已经被解决过的[问题#2760](https://github.com/artf/grapesjs/issues/2760),这是错了还是我做错了?我本以为资源不会显示出来,但它们全都可见 上,CleanID 仍然无法支持 MJML 代码。 这和这个已关闭的问题有关:https://github.com/artf/grapesjs/issues/3276 这个函数不会读取MJML标签:“attrs”是空的,我找不...
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
相关教程
关于同一主题的深入指南。
教程
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.
浏览插件分类
直接跳转到市场上的插件分类页面。