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 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.
|
||||
// 'this' must contain:
|
||||
@@ -222,10 +233,14 @@ export function previewFormatter(style, data, values, key) {
|
||||
attr.className = 'highlight preview';
|
||||
break;
|
||||
case 'LN':
|
||||
case 'MN':
|
||||
// Disable links in previews.
|
||||
el = 'span';
|
||||
break;
|
||||
case 'MN':
|
||||
// If mention starts with '➦', keep just that one symbol.
|
||||
values = extractMentionSymbol(values);
|
||||
el = 'span';
|
||||
break;
|
||||
case 'IM':
|
||||
// Replace image with '[icon] Image'.
|
||||
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);
|
||||
}
|
||||
;
|
||||
|
||||
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) {
|
||||
if (!style) {
|
||||
return values;
|
||||
@@ -632,7 +642,11 @@ function previewFormatter(style, data, values, key) {
|
||||
break;
|
||||
|
||||
case 'LN':
|
||||
el = 'span';
|
||||
break;
|
||||
|
||||
case 'MN':
|
||||
values = extractMentionSymbol(values);
|
||||
el = 'span';
|
||||
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