Added placeholder remover on post history

no issue

- removes the div containing the initial "Begin writing your post" from
  being part of the compared by the differ
This commit is contained in:
Ronald 2023-04-20 10:31:53 +01:00
parent f9e3813b08
commit 66e8d2a51e

View File

@ -78,10 +78,13 @@ export default ModalComponent.extend({
registerComparisonEditorApi(api) {
this.comparisonEditor = api;
}
},
// toggleDifferences() {
// this.toggleProperty('showDifferences');
// }
stripInitialPlaceholder(html) {
//TODO: we should probably add a data attribute to Koenig and grab that instead
const regex = /<div\b[^>]*>(\s*Begin writing your post\.\.\.\s*)<\/div>/i;
const strippedHtml = html.replace(regex, '');
return strippedHtml;
},
toggleDifferences: action(function () {
@ -151,8 +154,8 @@ export default ModalComponent.extend({
let updateIfBothDone = () => {
if (previousDone && currentDone) {
this.set('diffHtml', this.calculateHTMLDiff(previous.innerHTML, current.innerHTML));
this.set('selectedHTML', current.innerHTML);
this.set('diffHtml', this.calculateHTMLDiff(this.stripInitialPlaceholder(previous.innerHTML), this.stripInitialPlaceholder(current.innerHTML)));
this.set('selectedHTML', this.stripInitialPlaceholder(current.innerHTML));
}
};