diff --git a/src/dom_components/model/Components.ts b/src/dom_components/model/Components.ts index af1506033..1829b27f9 100644 --- a/src/dom_components/model/Components.ts +++ b/src/dom_components/model/Components.ts @@ -94,7 +94,8 @@ Component> { const prev = opts.previousModels || []; const toRemove = prev.filter(prev => !models.get(prev.cid)); const newIds = getComponentIds(models); - opts.keepIds = getComponentIds(prev).filter(pr => newIds.indexOf(pr) >= 0); + const idsToKeep = getComponentIds(prev).filter(pr => newIds.indexOf(pr) >= 0); + opts.keepIds = (opts.keepIds || []).concat(idsToKeep); toRemove.forEach(md => this.removeChildren(md, coll, opts)); models.each(model => this.onAdd(model)); } diff --git a/src/dom_components/view/ComponentTextView.ts b/src/dom_components/view/ComponentTextView.ts index 632c10a6d..d1bb77e3b 100644 --- a/src/dom_components/view/ComponentTextView.ts +++ b/src/dom_components/view/ComponentTextView.ts @@ -4,6 +4,7 @@ import RichTextEditorModule from '../../rich_text_editor'; import RichTextEditor from '../../rich_text_editor/model/RichTextEditor'; import { getModel, off, on } from '../../utils/mixins'; import Component from '../model/Component'; +import { getComponentIds } from '../model/Components'; import ComponentText from '../model/ComponentText'; import { ComponentDefinition } from '../model/types'; import ComponentView from './ComponentView'; @@ -152,7 +153,12 @@ export default class ComponentTextView extends ComponentView { // If there is a custom RTE the content is just baked staticly // inside 'content' if (rte?.customRte && !rte.customRte.parseContent) { - comps.length && comps.reset(undefined, opts); + comps.length && + comps.reset(undefined, { + ...opts, + // @ts-ignore + keepIds: getComponentIds(comps), + }); model.set('content', content, contentOpt); } else { comps.resetFromString(content, opts);