Merge 58dd7837a6 into 6bd3ed2074
This commit is contained in:
commit
da15d7a49b
3 changed files with 16 additions and 4 deletions
|
|
@ -17,6 +17,7 @@ import MkCode from '@/components/MkCode.vue';
|
|||
import MkCodeInline from '@/components/MkCodeInline.vue';
|
||||
import MkGoogle from '@/components/MkGoogle.vue';
|
||||
import MkSparkle from '@/components/MkSparkle.vue';
|
||||
import MkUrlPreview from '@/components/MkUrlPreview.vue';
|
||||
import MkA, { MkABehavior } from '@/components/global/MkA.vue';
|
||||
import { defaultStore } from '@/store.js';
|
||||
|
||||
|
|
@ -398,12 +399,19 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
|
|||
}
|
||||
|
||||
case 'quote': {
|
||||
if (!props.nowrap) {
|
||||
return [h('div', {
|
||||
if (props.nowrap) {
|
||||
return [h('span', {
|
||||
style: QUOTE_STYLE,
|
||||
}, genEl(token.children, scale, true))];
|
||||
} else if (token.children.length === 1 && token.children[0].type === 'url') {
|
||||
return [h('div', { style: 'padding-block: 8px' }, [
|
||||
h(MkUrlPreview, {
|
||||
url: token.children[0].props.url,
|
||||
compact: true,
|
||||
}),
|
||||
])];
|
||||
} else {
|
||||
return [h('span', {
|
||||
return [h('div', {
|
||||
style: QUOTE_STYLE,
|
||||
}, genEl(token.children, scale, true))];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,11 @@ import { unique } from '@/scripts/array.js';
|
|||
const removeHash = (x: string) => x.replace(/#[^#]*$/, '');
|
||||
|
||||
export function extractUrlFromMfm(nodes: mfm.MfmNode[], respectSilentFlag = true): string[] {
|
||||
const quotedUrlNodes = mfm.extract(nodes, (node) => {
|
||||
return (node.type === 'quote') && (node.children.length === 1) && (node.children[0].type === 'url');
|
||||
}).map(quote => quote.children[0]);
|
||||
const urlNodes = mfm.extract(nodes, (node) => {
|
||||
return (node.type === 'url') || (node.type === 'link' && (!respectSilentFlag || !node.props.silent));
|
||||
return (node.type === 'url' && !quotedUrlNodes.includes(node)) || (node.type === 'link' && (!respectSilentFlag || !node.props.silent));
|
||||
});
|
||||
const urls: string[] = unique(urlNodes.map(x => x.props.url));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue