@dialpad/dialtone
Version:
Dialpad's Dialtone design system monorepo
46 lines (45 loc) • 997 B
JavaScript
import Mention from "@tiptap/extension-mention";
import { mergeAttributes } from "@tiptap/core";
import { VueNodeViewRenderer } from "@tiptap/vue-2";
import { PluginKey } from "@tiptap/pm/state";
import MentionComponent from "./MentionComponent.vue.js";
const MentionPlugin = Mention.extend({
addNodeView() {
return VueNodeViewRenderer(MentionComponent);
},
parseHTML() {
return [
{
tag: "mention-component"
}
];
},
addAttributes() {
return {
name: {
default: ""
},
avatarSrc: {
default: ""
},
id: {
default: ""
}
};
},
renderText({ node }) {
return `@${node.attrs.id}`;
},
renderHTML({ HTMLAttributes }) {
return ["mention-component", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
}
}).configure({
suggestion: {
char: "@",
pluginKey: new PluginKey("mentionSuggestion")
}
});
export {
MentionPlugin
};
//# sourceMappingURL=mention.js.map