Merge branch 'recipients-inline' into 'develop'

Status: strip compatibility features from markup when importing

See merge request soapbox-pub/soapbox-fe!1004
improve-ci
Alex Gleason 2022-01-25 02:53:26 +00:00
commit d36f0f7aae
4 zmienionych plików z 23 dodań i 21 usunięć

Wyświetl plik

@ -1,5 +1,7 @@
import escapeTextContentForBrowser from 'escape-html';
import { stripCompatibilityFeatures } from 'soapbox/utils/html';
import emojify from '../../features/emoji/emoji';
import { unescapeHTML } from '../../utils/html';
@ -79,7 +81,7 @@ export function normalizeStatus(status, normalOldStatus, expandSpoilers) {
const emojiMap = makeEmojiMap(normalStatus);
normalStatus.search_index = domParser.parseFromString(searchContent, 'text/html').documentElement.textContent;
normalStatus.contentHtml = emojify(normalStatus.content, emojiMap);
normalStatus.contentHtml = stripCompatibilityFeatures(emojify(normalStatus.content, emojiMap));
normalStatus.spoilerHtml = emojify(escapeTextContentForBrowser(spoilerText), emojiMap);
normalStatus.hidden = expandSpoilers ? false : spoilerText.length > 0 || normalStatus.sensitive;
}

Wyświetl plik

@ -75,17 +75,6 @@ class StatusContent extends React.PureComponent {
}
}
deleteInlineQuote() {
const node = this.node;
if (!node) return;
const inlineQuote = node.querySelector('.quote-inline');
if (inlineQuote) {
inlineQuote.remove();
}
}
setCollapse() {
const node = this.node;
@ -117,7 +106,6 @@ class StatusContent extends React.PureComponent {
refresh = () => {
this.setCollapse();
this._updateStatusLinks();
this.deleteInlineQuote();
this.setOnlyEmoji();
}

Wyświetl plik

@ -4,3 +4,23 @@ export const unescapeHTML = (html) => {
wrapper.innerHTML = html.replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n').replace(/<[^>]*>/g, '');
return wrapper.textContent;
};
export const stripCompatibilityFeatures = html => {
const node = document.createElement('div');
node.innerHTML = html;
const selectors = [
'.quote-inline',
'.recipients-inline',
];
selectors.forEach(selector => {
const elem = node.querySelector(selector);
if (elem) {
elem.remove();
}
});
return node.innerHTML;
};

Wyświetl plik

@ -821,11 +821,3 @@ a.status-card.compact:hover {
margin-top: 5px !important;
}
}
/* Fedibird quote post compatibility */
.status__content,
.quoted-status__content {
.quote-inline {
display: none;
}
}