Browse Source

Avoid losing styles in default custom RTE

pull/5649/head
Artur Arseniev 3 years ago
parent
commit
b2dbc58aec
  1. 3
      src/dom_components/model/Components.ts
  2. 8
      src/dom_components/view/ComponentTextView.ts

3
src/dom_components/model/Components.ts

@ -94,7 +94,8 @@ Component> {
const prev = opts.previousModels || []; const prev = opts.previousModels || [];
const toRemove = prev.filter(prev => !models.get(prev.cid)); const toRemove = prev.filter(prev => !models.get(prev.cid));
const newIds = getComponentIds(models); 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)); toRemove.forEach(md => this.removeChildren(md, coll, opts));
models.each(model => this.onAdd(model)); models.each(model => this.onAdd(model));
} }

8
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 RichTextEditor from '../../rich_text_editor/model/RichTextEditor';
import { getModel, off, on } from '../../utils/mixins'; import { getModel, off, on } from '../../utils/mixins';
import Component from '../model/Component'; import Component from '../model/Component';
import { getComponentIds } from '../model/Components';
import ComponentText from '../model/ComponentText'; import ComponentText from '../model/ComponentText';
import { ComponentDefinition } from '../model/types'; import { ComponentDefinition } from '../model/types';
import ComponentView from './ComponentView'; 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 // If there is a custom RTE the content is just baked staticly
// inside 'content' // inside 'content'
if (rte?.customRte && !rte.customRte.parseContent) { 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); model.set('content', content, contentOpt);
} else { } else {
comps.resetFromString(content, opts); comps.resetFromString(content, opts);

Loading…
Cancel
Save