mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: support mention notification
This commit is contained in:
1 parent
d66c161e66
commit
ca00dda575
14 files changed
+67
-24
No files matched your search
@@ -123,12 +123,10 @@ monaco.editor.registerCommand('hydro.openUserPage', (accesser, uid) => {
|
||||
monaco.languages.registerCodeLensProvider('markdown', {
|
||||
async provideCodeLenses(model) {
|
||||
const users = model.findMatches('\\[\\]\\(/user/(\\d+)\\)', true, true, true, null, true);
|
||||
const { data } = await api(`
|
||||
query {
|
||||
users(ids: [${users.map((i) => i.matches[1]).join(',')}]) {
|
||||
_id
|
||||
uname
|
||||
}
|
||||
const { data } = await api(gql`
|
||||
users(ids: ${users.map((i) => +i.matches[1])}) {
|
||||
_id
|
||||
uname
|
||||
}
|
||||
`);
|
||||
return {
|
||||
@@ -172,6 +170,7 @@ monaco.languages.registerCompletionItemProvider('markdown', {
|
||||
_id
|
||||
uname
|
||||
avatarUrl
|
||||
priv
|
||||
}
|
||||
`, ['data', 'users']);
|
||||
return {
|
||||
@@ -179,8 +178,9 @@ monaco.languages.registerCompletionItemProvider('markdown', {
|
||||
label: `@${i.uname} (UID=${i._id})`,
|
||||
kind: monaco.languages.CompletionItemKind.Property,
|
||||
documentation: { value: ``, isTrusted: true },
|
||||
insertText: `[](/user/${i._id}) `,
|
||||
insertText: `@[](/user/${i._id}) `,
|
||||
range,
|
||||
sortText: i.priv === 0 ? '0' : '1',
|
||||
tags: i.priv === 0 ? [1] : [],
|
||||
})),
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user