UNPKG

@dialpad/dialtone-vue

Version:

Vue component library for Dialpad's design system Dialtone

1 lines 1.86 kB
{"version":3,"file":"custom_link.cjs","sources":["../../../../../components/rich_text_editor/extensions/custom_link/custom_link.js"],"sourcesContent":["/**\n *\n * The custom link does some additional things on top of the built in TipTap link\n * extension such as styling phone numbers and IP adresses as links, and allows you\n * to linkify text without having to type a space after the link. Currently it is missing some\n * functionality such as editing links and will likely require more work to be fully usable,\n * so it is recommended to use the built in TipTap link for now.\n */\n\nimport {\n mergeAttributes,\n Mark,\n} from '@tiptap/core';\nimport { autolink } from './autolink';\n\nconst defaultAttributes = {\n class: 'd-link d-c-text d-d-inline-block d-wb-break-all',\n rel: 'noopener noreferrer nofollow',\n};\n\n// This is the actual extension code, which is mostly showing that all the\n// functionality comes from the ProseMirror plugin.\nexport const CustomLink = Mark.create({\n name: 'CustomLink',\n\n renderHTML ({ HTMLAttributes }) {\n return [\n 'a',\n mergeAttributes(\n this.options.HTMLAttributes,\n HTMLAttributes,\n defaultAttributes,\n ),\n ];\n },\n\n renderText ({ node }) {\n return node.attrs.text;\n },\n\n addProseMirrorPlugins () {\n return [\n autolink({ type: this.type }),\n ];\n },\n});\n"],"names":["Mark","mergeAttributes","autolink"],"mappings":";;;;AAeA,MAAM,oBAAoB;AAAA,EACxB,OAAO;AAAA,EACP,KAAK;AACP;AAIY,MAAC,aAAaA,KAAI,KAAC,OAAO;AAAA,EACpC,MAAM;AAAA,EAEN,WAAY,EAAE,kBAAkB;AAC9B,WAAO;AAAA,MACL;AAAA,MACAC,KAAe;AAAA,QACb,KAAK,QAAQ;AAAA,QACb;AAAA,QACA;AAAA,MACD;AAAA,IACP;AAAA,EACG;AAAA,EAED,WAAY,EAAE,QAAQ;AACpB,WAAO,KAAK,MAAM;AAAA,EACnB;AAAA,EAED,wBAAyB;AACvB,WAAO;AAAA,MACLC,SAAAA,SAAS,EAAE,MAAM,KAAK,KAAI,CAAE;AAAA,IAClC;AAAA,EACG;AACH,CAAC;;"}