How to refresh/re-render after new node added?
优化后的“TextEditor.vue”文件: “''js // ... onFontValidate () { const { rte } = this.getRteData() const spanNode = document.createElement('span') 设 anchorNode = {} this.selection.childNodes.forEach(childNode => { console.log({ childNode }) if (childNode.textContent !== this.selection.anchorText) { 回归 } anchorNode = childNode...
阅读下方完整回答 ↓问题
我会手动在渲染组件中添加一个新节点。 视觉效果还可以,但无法保存,因为我的风格不是用自动生成的GrapesJS ID。 要手动解决这个难题,我双击要进入的组件,然后在画布主体中点击外部。然后,将 GrapesJS ID 和 'data-gjs-type='text' 添加到新节点,从而可以保存。 Vue.js: “Main.vue”文件的一部分: “''js 文本编辑器 https://grapesjs.com/docs/api/richtexteditor.html https://css-tricks.com/creating-vue-js-component-instances-programmatically/ const editorToolbar = editorRte.getToolbarEl() const TextEditorClass = Vue.extend(TextEditor) const textEditor = new TextEditorClass({ propsData: { 编辑:这个。编辑 } }) textEditor.$mount() editorToolbar.innerHTML = '' editorToolbar.appendChild(textEditor.$el) editorToolbar.classList.replace(...
回答(3)
优化后的“TextEditor.vue”文件: “''js // ... onFontValidate () { const { rte } = this.getRteData() const spanNode = document.createElement('span') 设 anchorNode = {} this.selection.childNodes.forEach(childNode => { console.log({ childNode }) if (childNode.textContent !== this.selection.anchorText) { 回归 } an...
i️ 它不能直接用 HTML,只能用 JSON。 Component = JSON 节点(html元素 + GrapesJS 数据) “''js addStylesToText (styles, tagName = 'span') { const inlineStyles = styles.map(style => style.join(':')).join(';') + ';' const selectedComponent = this.editor.getSelected() const components = selectedComponent.components().model...
谢谢你举报,@bgrand-ch。 关于新节点添加后如何刷新/重新渲染?的好问题。ProseMirror 推荐的方法是使用事件驱动的 API。 从这里开始: 查看你所在模块的[GrapesJS文档](https://grapesjs.com/docs/) 寻找“on()”事件监听器方法 大多数操作可以通过监听编辑器和组件事件来实现 常见模式: “JavaScript 留意变化 editor.on('change', () => console.log('something changed')); 组件生命周期 editor.on('component:mount', (c) => conso...
相关问答
通过相似的问题讨论继续研究。
问题 #3599
@keyframes即使我通过关键帧对象后也没有添加
你好,@artf, 我已经添加了 '让CC = 编辑器。Css作曲家; cc.setRule('.fadetop-animate', { 不透明度:0,'animation-name': 'fadeTop' }, { atRuleType: 'keyframes', atRul...
问题 #3688
How to customize a component
我 https://grapesjs.com/docs/modules/Components.html#define-custom-component-type 读了这份文档,并尝试编写以下代码。我想让“mj-body”无法删除: 但我看不到效果,请帮帮我
问题 #3406
如何创建自定义存储管理器?它不会在重新加载页面后从Canvas中设置保存数据
大家好,我想把 Canvas 上的数据保存到 Redux 存储,这样可以,但重新加载页面后,存储加载方法没有把我的数据设置为构建器(Canvas),我不知道问题出在哪里,如果有人有解决办法请告诉我。 代码示例: “''js Grapejs.init({ .../// stora...
问题 #5460
从“pageManager”加载“组件”和“样式”
GrapesJS版本[X] 我确认使用最新版本GrapesJS你用的是什么浏览器? Chrome v117.0.5938.149可复制演示链接 https://jsfiddle.net/9oLrsvya/描述一下那个虫子 如何复现这个漏洞?请查看jsfiddle中的pageMa...
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
相关教程
关于同一主题的深入指南。
教程
Introducing Search on GJS.Market
GJS.Market now has one search across everything we publish — plugins, articles, community questions, guides, authors and services. Press ⌘K from any page.
教程
如何在2026年用 GrapesJS 构建AI驱动的页面构建器
我们构建GJSDocs的经验——从简单的AI文本生成到结构化、上下文感知的视觉编辑
教程
2026年构建一个SaaS页面构建器需要多少钱?
2026年构建一个SaaS页面构建器的成本是多少?探索实际的开发成本、时间表、功能,以及使用 GrapesJS 如何降低成本
浏览插件分类
直接跳转到市场上的插件分类页面。