- {{#if (and this.diffHtml this.showDifferences (feature 'postDiffing'))}}
- {{{this.diffHtml}}}
- {{else if this.selectedHTML}}
+
+ {{#if this.selectedHTML}}
{{{this.selectedHTML}}}
{{/if}}
-
-
-
- {{#if this.comparisonRevision.feature_image}}
-

- {{/if}}
- {{#if this.comparisonRevision.feature_image_caption}}
-
{{{this.comparisonRevision.feature_image_caption}}}"
- {{/if}}
-
-
-
{{this.previousTitle}}
-
-
@@ -69,7 +53,7 @@
{{#if (eq revision.reason "unpublished")}}
Unpublished
{{/if}}
-
+
@@ -90,21 +74,6 @@
{{/each}}
- {{#if (feature 'postDiffing')}}
-
- {{/if}}
diff --git a/ghost/admin/app/components/modal-post-history.js b/ghost/admin/app/components/modal-post-history.js
index 07c3967de2..7e22998d8a 100644
--- a/ghost/admin/app/components/modal-post-history.js
+++ b/ghost/admin/app/components/modal-post-history.js
@@ -1,6 +1,5 @@
import Component from '@glimmer/component';
import RestoreRevisionModal from '../components/modals/restore-revision';
-import diff from 'node-htmldiff';
import {action, set} from '@ember/object';
import {inject as service} from '@ember/service';
import {tracked} from '@glimmer/tracking';
@@ -23,11 +22,8 @@ function checkFinishedRendering(element, done) {
export default class ModalPostHistory extends Component {
@service notifications;
@service modals;
- @service feature;
@service ghostPaths;
@tracked selectedHTML = null;
- @tracked diffHtml = null;
- @tracked showDifferences = this.feature.get('postDiffing'); // should default to true in future
@tracked selectedRevisionIndex = 0;
constructor() {
@@ -41,20 +37,12 @@ export default class ModalPostHistory extends Component {
return this.revisionList[this.selectedRevisionIndex];
}
- get comparisonRevision() {
- return this.revisionList[this.selectedRevisionIndex + 1] || this.selectedRevision;
- }
-
- get previousTitle() {
- return this.comparisonRevision.title || this.post.get('title');
- }
-
get currentTitle() {
return this.selectedRevision.title || this.post.get('title');
}
get revisionList() {
- const revisions = this.post.get('postRevisions').toArray().sort((a, b) => b.get('createdAt') - a.get('createdAt'));
+ const revisions = this.post.get('postRevisions').toArray().sort((a, b) => b.get('createdAt') - a.get('createdAt'));
return revisions.map((revision, index) => {
return {
lexical: revision.get('lexical'),
@@ -78,7 +66,7 @@ export default class ModalPostHistory extends Component {
@action
onInsert() {
- this.updateDiff();
+ this.updateSelectedHTML();
window.addEventListener('keydown', this.handleKeyDown);
}
@@ -98,7 +86,7 @@ export default class ModalPostHistory extends Component {
@action
handleClick(index) {
this.selectedRevisionIndex = index;
- this.updateDiff();
+ this.updateSelectedHTML();
}
@action
@@ -143,97 +131,35 @@ export default class ModalPostHistory extends Component {
});
}
- @action
- toggleDifferences() {
- this.showDifferences = !this.showDifferences;
- }
-
get cardConfig() {
return {
post: this.args.model
};
}
- calculateHTMLDiff(previousHTML, currentHTML) {
- const result = diff(previousHTML, currentHTML);
- const div = document.createElement('div');
- div.innerHTML = result;
- this.diffCards(div);
- return div.innerHTML;
- }
-
- diffCards(div) {
- const cards = div.querySelectorAll('div[data-kg-card]');
- for (const card of cards) {
- const hasChanges = !!card.querySelectorAll('del').length || !!card.querySelectorAll('ins').length;
- if (hasChanges) {
- const delCard = card.cloneNode(true);
- const insCard = card.cloneNode(true);
-
- const ins = document.createElement('ins');
- const del = document.createElement('del');
-
- delCard.querySelectorAll('ins').forEach((el) => {
- el.remove();
- });
- insCard.querySelectorAll('del').forEach((el) => {
- el.remove();
- });
- delCard.querySelectorAll('del').forEach((el) => {
- el.parentNode.appendChild(el.firstChild);
- el.remove();
- });
- insCard.querySelectorAll('ins').forEach((el) => {
- el.parentNode.appendChild(el.firstChild);
- el.remove();
- });
-
- ins.appendChild(insCard);
- del.appendChild(delCard);
-
- card.parentNode.appendChild(del);
- card.parentNode.appendChild(ins);
- card.remove();
- }
- }
- }
-
- updateDiff() {
- if (this.comparisonEditor && this.selectedEditor) {
- let comparisonState = this.comparisonEditor.editorInstance.parseEditorState(this.comparisonRevision.lexical);
+ updateSelectedHTML() {
+ if (this.selectedEditor) {
let selectedState = this.selectedEditor.editorInstance.parseEditorState(this.selectedRevision.lexical);
- this.comparisonEditor.editorInstance.setEditorState(comparisonState);
this.selectedEditor.editorInstance.setEditorState(selectedState);
}
- let previous = document.querySelector('.gh-post-history-hidden-lexical.previous');
let current = document.querySelector('.gh-post-history-hidden-lexical.current');
- let previousDone = false;
let currentDone = false;
- let updateIfBothDone = () => {
- if (previousDone && currentDone) {
- this.diffHtml = this.calculateHTMLDiff(this.stripInitialPlaceholder(previous.innerHTML), this.stripInitialPlaceholder(current.innerHTML));
+ let updateIfDone = () => {
+ if (currentDone) {
this.selectedHTML = this.stripInitialPlaceholder(current.innerHTML);
}
};
- checkFinishedRendering(previous, () => {
- previous.querySelectorAll('[contenteditable]').forEach((el) => {
- el.setAttribute('contenteditable', false);
- });
- previousDone = true;
- updateIfBothDone();
- });
-
checkFinishedRendering(current, () => {
current.querySelectorAll('[contenteditable]').forEach((el) => {
el.setAttribute('contenteditable', false);
});
currentDone = true;
- updateIfBothDone();
+ updateIfDone();
});
}
}
diff --git a/ghost/admin/app/services/feature.js b/ghost/admin/app/services/feature.js
index 7c6e33806f..b30789b2a6 100644
--- a/ghost/admin/app/services/feature.js
+++ b/ghost/admin/app/services/feature.js
@@ -68,7 +68,6 @@ export default class FeatureService extends Service {
@feature('stripeAutomaticTax') stripeAutomaticTax;
@feature('emailCustomization') emailCustomization;
@feature('i18n') i18n;
- @feature('postDiffing') postDiffing;
@feature('announcementBar') announcementBar;
@feature('imageEditor') imageEditor;
@feature('signupCard') signupCard;
diff --git a/ghost/admin/app/styles/layouts/post-history.css b/ghost/admin/app/styles/layouts/post-history.css
index f3242bf5a0..807bd1065f 100644
--- a/ghost/admin/app/styles/layouts/post-history.css
+++ b/ghost/admin/app/styles/layouts/post-history.css
@@ -175,52 +175,6 @@
color: var(--black);
}
-.gh-post-history .show-diff .gh-editor-feature-image img {
- opacity: .5;
-}
-
-.gh-post-history .show-diff .gh-editor-feature-image del img {
- opacity: 1;
- border: 3px solid var(--white);
- box-shadow: 0 0 0 2px var(--red);
-}
-
-.gh-post-history .show-diff .gh-editor-feature-image ins img {
- opacity: 1;
- border: 3px solid var(--white);
- box-shadow: 0 0 0 2px var(--green);
-}
-
-.gh-post-history .show-diff .gh-editor-title {
- opacity: .4;
-}
-
-.gh-post-history-main .show-diff .koenig-lexical h1,
-.gh-post-history-main .show-diff .koenig-lexical h2,
-.gh-post-history-main .show-diff .koenig-lexical h3,
-.gh-post-history-main .show-diff .koenig-lexical h4,
-.gh-post-history-main .show-diff .koenig-lexical h5,
-.gh-post-history-main .show-diff .koenig-lexical h6,
-.gh-post-history-main .show-diff .koenig-lexical p,
-.gh-post-history-main .show-diff .koenig-lexical blockquote,
-.gh-post-history-main .show-diff .koenig-lexical aside {
- color: rgba(21, 23, 26, 0.4);
-}
-
-.gh-post-history-main .show-diff .koenig-lexical a:not(.gh-post-history-main .koenig-lexical del a):not(.gh-post-history-main .koenig-lexical ins a) {
- opacity: .4;
-}
-
-.gh-post-history-main .koenig-lexical del {
- color: var(--red-d1) !important;
-}
-
-.gh-post-history-main .koenig-lexical ins {
- color: var(--black) !important;
- text-decoration: none !important;
- background-color: rgba(48, 207, 67, 0.15) !important;
-}
-
.gh-post-history-hidden-lexical {
display: none;
}
diff --git a/ghost/admin/app/templates/settings/labs.hbs b/ghost/admin/app/templates/settings/labs.hbs
index 4a1d42fe4b..57e5e6305c 100644
--- a/ghost/admin/app/templates/settings/labs.hbs
+++ b/ghost/admin/app/templates/settings/labs.hbs
@@ -268,20 +268,6 @@