Replies: 4 comments
-
I haven't used this library before. But I think this feature can be implemented with I will also try it out later on |
Beta Was this translation helpful? Give feedback.
-
I tried it @imzbf , but it still doesn't work.. |
Beta Was this translation helpful? Give feedback.
-
I'm sorry, I didn't have time to have a try before. This is an example, I will optimize styles in the next version. import { autocompletion, CompletionContext } from '@codemirror/autocomplete';
const myCompletions = (context: CompletionContext) => {
const word = context.matchBefore(/^@*/);
if (word!.from == word!.to && !context.explicit) return null;
return {
from: word!.from,
options: [
{ label: '@imzbf', type: 'text' },
{ label: '@github', type: 'text' }
]
};
};
config({
codeMirrorExtensions(_theme, extensions) {
const _exs = [
...extensions,
lineNumbers(),
autocompletion({ override: [myCompletions] })
];
// _exs[1] = basicSetup;
return _exs;
}
}); |
Beta Was this translation helpful? Give feedback.
-
I will optimize styles in And we can use <template>
<MdEditor v-model="text" :completions="completions" />
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { MdEditor } from 'md-editor-v3';
import 'md-editor-v3/lib/style.css';
import type { CompletionSource } from '@codemirror/autocomplete';
const text = ref('');
const completions = ref<Array<CompletionSource>>([
(context) => {
const word = context.matchBefore(/@\w*/);
if (word === null || (word.from == word.to && context.explicit)) {
return null;
}
return {
from: word.from,
options: [
{
label: '@imzbf',
type: 'text'
}
]
};
}
]);
</script> |
Beta Was this translation helpful? Give feedback.
-
Hi,
Is it possible to add mention in markdown ?
I am trying to add in my project with this package: https://www.npmjs.com/package/vue-mention
but working only for input and textarea.
Beta Was this translation helpful? Give feedback.
All reactions