strip mentioned name from the forwarded preview
This commit is contained in:
+17
-2
@@ -192,7 +192,18 @@ export function fullFormatter(style, data, values, key) {
|
|||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
return React.createElement(el, attr, values);
|
return React.createElement(el, attr, values);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
// Unexported utility function: extract '➦' from mention if it's the first symbol,
|
||||||
|
// otherwise return the whole mention.
|
||||||
|
function extractMentionSymbol(content) {
|
||||||
|
if (Array.isArray(content) && content.length > 0) {
|
||||||
|
content = extractMentionSymbol(content[0]);
|
||||||
|
} else if (typeof content == 'string' && content.startsWith('➦')) {
|
||||||
|
content = ['➦'];
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
// Converts Drafty object into a one-line preview. 'this' is set by the caller.
|
// Converts Drafty object into a one-line preview. 'this' is set by the caller.
|
||||||
// 'this' must contain:
|
// 'this' must contain:
|
||||||
@@ -222,10 +233,14 @@ export function previewFormatter(style, data, values, key) {
|
|||||||
attr.className = 'highlight preview';
|
attr.className = 'highlight preview';
|
||||||
break;
|
break;
|
||||||
case 'LN':
|
case 'LN':
|
||||||
case 'MN':
|
|
||||||
// Disable links in previews.
|
// Disable links in previews.
|
||||||
el = 'span';
|
el = 'span';
|
||||||
break;
|
break;
|
||||||
|
case 'MN':
|
||||||
|
// If mention starts with '➦', keep just that one symbol.
|
||||||
|
values = extractMentionSymbol(values);
|
||||||
|
el = 'span';
|
||||||
|
break;
|
||||||
case 'IM':
|
case 'IM':
|
||||||
// Replace image with '[icon] Image'.
|
// Replace image with '[icon] Image'.
|
||||||
el = React.Fragment;
|
el = React.Fragment;
|
||||||
|
|||||||
+15
-1
@@ -606,7 +606,17 @@ function fullFormatter(style, data, values, key) {
|
|||||||
|
|
||||||
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(el, attr, values);
|
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(el, attr, values);
|
||||||
}
|
}
|
||||||
;
|
|
||||||
|
function extractMentionSymbol(content) {
|
||||||
|
if (Array.isArray(content) && content.length > 0) {
|
||||||
|
content = extractMentionSymbol(content[0]);
|
||||||
|
} else if (typeof content == 'string' && content.startsWith('➦')) {
|
||||||
|
content = ['➦'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
function previewFormatter(style, data, values, key) {
|
function previewFormatter(style, data, values, key) {
|
||||||
if (!style) {
|
if (!style) {
|
||||||
return values;
|
return values;
|
||||||
@@ -632,7 +642,11 @@ function previewFormatter(style, data, values, key) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'LN':
|
case 'LN':
|
||||||
|
el = 'span';
|
||||||
|
break;
|
||||||
|
|
||||||
case 'MN':
|
case 'MN':
|
||||||
|
values = extractMentionSymbol(values);
|
||||||
el = 'span';
|
el = 'span';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user