Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inner quote #74

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,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 { host } from '@/config.js';
import { defaultStore } from '@/store.js';
Expand Down Expand Up @@ -388,12 +389,16 @@ 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(MkUrlPreview, {
url: token.children[0].props.url,
})];
} else {
return [h('span', {
return [h('div', {
style: QUOTE_STYLE,
}, genEl(token.children, scale, true))];
}
Expand Down
5 changes: 4 additions & 1 deletion packages/frontend/src/scripts/extract-url-from-mfm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
Loading