AddType 问题,自定义类型在编辑器初始化时无法使用
目前还没有社区回答。打开 GitHub 上的原始讨论,分享你的解决方案。
问题
注意“addType”功能存在一些问题 如果我创建类似这样的自定义类型: 当我们在页面上添加组件小部件时,它运行良好 但保存内容到服务器并重新加载页面后,自定义类型就不适用了 因为“Parser”没有这种类型^,所以只使用默认类型,所以在小部件类型中不要调用“isComponent”方法。 这里:https://github.com/artf/grapesjs/blob/dev/src/parser/model/ParserHtml.js#L131 你知道这个bug吗? 可能的解决方案是在这里添加一些中间件,在调用“init”前添加自定义类型和组件到 instance 中。 https://github.com/artf/grapesjs/blob/dev/src/index.js#L52 *
回答(0)
暂无回答。
相关问答
通过相似的问题讨论继续研究。
问题 #1493
Render() 第一次通话时能正常工作,但后续通话则不行
你好, 我创建了一个自定义组件,用“背景图像”显示图像,<div>而不是用“<img>''元素。大部分时间还能用,只是每次我更改它的“src”特性时,都必须重新加载编辑器来预览渲染后的元素。这是其观点: “''js 查看:originalMap.view.extend({ in...
问题 #1998
扩展链接组件无法正常工作。
你好@hello @artf 我正在尝试扩展链接组件,并添加新的特征,比如 href 和 target,代码如下所示。 ''function loadWithOption(opts) { 编辑。DomComponents.addType('link', { model: dMo...
问题 #2405
替换特征文本时,ckeditor 未被初始化
为什么当我更改CKeditor特性文本时,它没有被初始化 我的特质 <pre> domComps.addType('text',{ model: dModel.extend({ defaults: Object.assign({}, dModel.prototype.defau...
问题 #400
隐藏命令中的一个元素
你好, 我想在点击工具栏按钮时隐藏某个特定元素 命令:{ 默认值:[{ id:“submenuitem”, run: function(editor, senderBtn){ 我想隐藏“photostack-1”元素 ???? ???? ???? }, }], } VAR DO...
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
相关教程
关于同一主题的深入指南。
教程
GrapesJS custom components guide (2026)
Define custom GrapesJS components with DomComponents.addType: detection with isComponent, a model with traits and defaults, and a view for canvas behavior.
教程
How to add a custom block in GrapesJS (2026)
Add custom drag-and-drop blocks to GrapesJS with the Block Manager: content, categories, media icons, and reusable component-backed blocks.
教程
Integrating GrapesJS into a Vue 3 App — Complete Guide for 2026
Build a Vue 3 landing page builder with GrapesJS and Vite. Custom blocks, composables, remote storage, TypeScript & production tips. Updated for 2026.
浏览插件分类
直接跳转到市场上的插件分类页面。