新节点添加后,如何刷新/重新渲染?
优化后的“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...
问题 #5316
编辑者未订阅选择器:移除
葡萄JS版本[X] 我确认使用最新版本的GrapesJS你用的是什么浏览器? Chrome v115.0.5790.170可复制演示链接 https://jsfiddle.net/BenKhz/yfwqc6mu/1/ 参考[这里的文档](https://grapesjs.com...
问题 #3406
如何创建自定义存储管理器?它不会在重新加载页面后从Canvas中设置保存数据
大家好,我想把 Canvas 上的数据保存到 Redux 存储,这样可以,但重新加载页面后,存储加载方法没有把我的数据设置为构建器(Canvas),我不知道问题出在哪里,如果有人有解决办法请告诉我。 代码示例: “''js Grapejs.init({ .../// stora...
问题 #5460
从“pageManager”加载“组件”和“样式”
葡萄JS版本[X] 我确认使用最新版本的GrapesJS你用的是什么浏览器? Chrome v117.0.5938.149可复制演示链接 https://jsfiddle.net/9oLrsvya/描述一下那个虫子 如何复现这个漏洞?请参见 jsfiddle 中的“pageMa...
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
相关教程
关于同一主题的深入指南。
教程
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.
浏览插件分类
直接跳转到市场上的插件分类页面。