From 66e8d2a51e209196829ef600dd7043d7c178ce3c Mon Sep 17 00:00:00 2001 From: Ronald Date: Thu, 20 Apr 2023 10:31:53 +0100 Subject: [PATCH] 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 --- ghost/admin/app/components/modal-post-history.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ghost/admin/app/components/modal-post-history.js b/ghost/admin/app/components/modal-post-history.js index f4e06b4c9a..9bdb99362f 100644 --- a/ghost/admin/app/components/modal-post-history.js +++ b/ghost/admin/app/components/modal-post-history.js @@ -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 = /]*>(\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)); } };