mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-24 21:45:06 +01:00
Use plaintext value for field value tooltips in web UI (#7388)
Fix #7383
This commit is contained in:
parent
db012b57c2
commit
d185f3ddaf
@ -1,5 +1,6 @@
|
|||||||
import escapeTextContentForBrowser from 'escape-html';
|
import escapeTextContentForBrowser from 'escape-html';
|
||||||
import emojify from '../../features/emoji/emoji';
|
import emojify from '../../features/emoji/emoji';
|
||||||
|
import { unescapeHTML } from '../../utils/html';
|
||||||
|
|
||||||
const domParser = new DOMParser();
|
const domParser = new DOMParser();
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ export function normalizeAccount(account) {
|
|||||||
...pair,
|
...pair,
|
||||||
name_emojified: emojify(escapeTextContentForBrowser(pair.name)),
|
name_emojified: emojify(escapeTextContentForBrowser(pair.name)),
|
||||||
value_emojified: emojify(pair.value, emojiMap),
|
value_emojified: emojify(pair.value, emojiMap),
|
||||||
|
value_plain: unescapeHTML(pair.value),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
importFetchedStatuses,
|
importFetchedStatuses,
|
||||||
} from './importer';
|
} from './importer';
|
||||||
import { defineMessages } from 'react-intl';
|
import { defineMessages } from 'react-intl';
|
||||||
|
import { unescapeHTML } from '../utils/html';
|
||||||
|
|
||||||
export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
|
export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
|
||||||
export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP';
|
export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP';
|
||||||
@ -31,13 +32,6 @@ const fetchRelatedRelationships = (dispatch, notifications) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const unescapeHTML = (html) => {
|
|
||||||
const wrapper = document.createElement('div');
|
|
||||||
html = html.replace(/<br \/>|<br>|\n/g, ' ');
|
|
||||||
wrapper.innerHTML = html;
|
|
||||||
return wrapper.textContent;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function updateNotifications(notification, intlMessages, intlLocale) {
|
export function updateNotifications(notification, intlMessages, intlLocale) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const showInColumn = getState().getIn(['settings', 'notifications', 'shows', notification.type], true);
|
const showInColumn = getState().getIn(['settings', 'notifications', 'shows', notification.type], true);
|
||||||
|
@ -146,7 +146,7 @@ export default class Header extends ImmutablePureComponent {
|
|||||||
{fields.map((pair, i) => (
|
{fields.map((pair, i) => (
|
||||||
<dl key={i}>
|
<dl key={i}>
|
||||||
<dt dangerouslySetInnerHTML={{ __html: pair.get('name_emojified') }} title={pair.get('name')} />
|
<dt dangerouslySetInnerHTML={{ __html: pair.get('name_emojified') }} title={pair.get('name')} />
|
||||||
<dd dangerouslySetInnerHTML={{ __html: pair.get('value_emojified') }} title={pair.get('value')} />
|
<dd dangerouslySetInnerHTML={{ __html: pair.get('value_emojified') }} title={pair.get('value_plain')} />
|
||||||
</dl>
|
</dl>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
6
app/javascript/mastodon/utils/html.js
Normal file
6
app/javascript/mastodon/utils/html.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export const unescapeHTML = (html) => {
|
||||||
|
const wrapper = document.createElement('div');
|
||||||
|
html = html.replace(/<br \/>|<br>|\n/g, ' ');
|
||||||
|
wrapper.innerHTML = html;
|
||||||
|
return wrapper.textContent;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user