UNPKG

@dialpad/dialtone

Version:

Dialpad's Dialtone design system monorepo

47 lines (46 loc) 1.02 kB
import Mention from "@tiptap/extension-mention"; import { mergeAttributes } from "@tiptap/core"; import { VueNodeViewRenderer } from "@tiptap/vue-2"; import { PluginKey } from "@tiptap/pm/state"; import ChannelComponent from "./ChannelComponent.vue.js"; const ChannelPlugin = Mention.extend({ name: "channel", addNodeView() { return VueNodeViewRenderer(ChannelComponent); }, parseHTML() { return [ { tag: "channel-component" } ]; }, addAttributes() { return { name: { default: "" }, id: { default: "" }, locked: { default: false } }; }, renderText({ node }) { return `#${node.attrs.id}`; }, renderHTML({ HTMLAttributes }) { return ["channel-component", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)]; } }).configure({ suggestion: { char: "#", pluginKey: new PluginKey("channelSuggestion") } }); export { ChannelPlugin }; //# sourceMappingURL=channel.js.map