@tiptap/extension-link 2.0.0-beta.19 → 2.0.0-beta.194

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ import { MarkType } from 'prosemirror-model';
2
+ import { Plugin } from 'prosemirror-state';
3
+ declare type AutolinkOptions = {
4
+ type: MarkType;
5
+ validate?: (url: string) => boolean;
6
+ };
7
+ export declare function autolink(options: AutolinkOptions): Plugin;
8
+ export {};
@@ -0,0 +1,7 @@
1
+ import { MarkType } from 'prosemirror-model';
2
+ import { Plugin } from 'prosemirror-state';
3
+ declare type ClickHandlerOptions = {
4
+ type: MarkType;
5
+ };
6
+ export declare function clickHandler(options: ClickHandlerOptions): Plugin;
7
+ export {};
@@ -0,0 +1,9 @@
1
+ import { Editor } from '@tiptap/core';
2
+ import { MarkType } from 'prosemirror-model';
3
+ import { Plugin } from 'prosemirror-state';
4
+ declare type PasteHandlerOptions = {
5
+ editor: Editor;
6
+ type: MarkType;
7
+ };
8
+ export declare function pasteHandler(options: PasteHandlerOptions): Plugin;
9
+ export {};
@@ -1,5 +1,13 @@
1
1
  import { Mark } from '@tiptap/core';
2
2
  export interface LinkOptions {
3
+ /**
4
+ * If enabled, it adds links as you type.
5
+ */
6
+ autolink: boolean;
7
+ /**
8
+ * An array of custom protocols to be registered with linkifyjs.
9
+ */
10
+ protocols: Array<string>;
3
11
  /**
4
12
  * If enabled, links will be opened on click.
5
13
  */
@@ -12,6 +20,12 @@ export interface LinkOptions {
12
20
  * A list of HTML attributes to be rendered.
13
21
  */
14
22
  HTMLAttributes: Record<string, any>;
23
+ /**
24
+ * A validation function that modifies link verification for the auto linker.
25
+ * @param url - The url to be validated.
26
+ * @returns - True if the url is valid, false otherwise.
27
+ */
28
+ validate?: (url: string) => boolean;
15
29
  }
16
30
  declare module '@tiptap/core' {
17
31
  interface Commands<ReturnType> {
@@ -37,12 +51,4 @@ declare module '@tiptap/core' {
37
51
  };
38
52
  }
39
53
  }
40
- /**
41
- * A regex that matches any string that contains a link
42
- */
43
- export declare const pasteRegex: RegExp;
44
- /**
45
- * A regex that matches an url
46
- */
47
- export declare const pasteRegexExact: RegExp;
48
- export declare const Link: Mark<LinkOptions>;
54
+ export declare const Link: Mark<LinkOptions, any>;
@@ -3,27 +3,157 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@tiptap/core');
6
+ var linkifyjs = require('linkifyjs');
6
7
  var prosemirrorState = require('prosemirror-state');
7
8
 
8
- /**
9
- * A regex that matches any string that contains a link
10
- */
11
- const pasteRegex = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)/gi;
12
- /**
13
- * A regex that matches an url
14
- */
15
- const pasteRegexExact = /^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)$/gi;
9
+ function autolink(options) {
10
+ return new prosemirrorState.Plugin({
11
+ key: new prosemirrorState.PluginKey('autolink'),
12
+ appendTransaction: (transactions, oldState, newState) => {
13
+ const docChanges = transactions.some(transaction => transaction.docChanged)
14
+ && !oldState.doc.eq(newState.doc);
15
+ const preventAutolink = transactions.some(transaction => transaction.getMeta('preventAutolink'));
16
+ if (!docChanges || preventAutolink) {
17
+ return;
18
+ }
19
+ const { tr } = newState;
20
+ const transform = core.combineTransactionSteps(oldState.doc, [...transactions]);
21
+ const { mapping } = transform;
22
+ const changes = core.getChangedRanges(transform);
23
+ changes.forEach(({ oldRange, newRange }) => {
24
+ // at first we check if we have to remove links
25
+ core.getMarksBetween(oldRange.from, oldRange.to, oldState.doc)
26
+ .filter(item => item.mark.type === options.type)
27
+ .forEach(oldMark => {
28
+ const newFrom = mapping.map(oldMark.from);
29
+ const newTo = mapping.map(oldMark.to);
30
+ const newMarks = core.getMarksBetween(newFrom, newTo, newState.doc)
31
+ .filter(item => item.mark.type === options.type);
32
+ if (!newMarks.length) {
33
+ return;
34
+ }
35
+ const newMark = newMarks[0];
36
+ const oldLinkText = oldState.doc.textBetween(oldMark.from, oldMark.to, undefined, ' ');
37
+ const newLinkText = newState.doc.textBetween(newMark.from, newMark.to, undefined, ' ');
38
+ const wasLink = linkifyjs.test(oldLinkText);
39
+ const isLink = linkifyjs.test(newLinkText);
40
+ // remove only the link, if it was a link before too
41
+ // because we don’t want to remove links that were set manually
42
+ if (wasLink && !isLink) {
43
+ tr.removeMark(newMark.from, newMark.to, options.type);
44
+ }
45
+ });
46
+ // now let’s see if we can add new links
47
+ core.findChildrenInRange(newState.doc, newRange, node => node.isTextblock)
48
+ .forEach(textBlock => {
49
+ // we need to define a placeholder for leaf nodes
50
+ // so that the link position can be calculated correctly
51
+ const text = newState.doc.textBetween(textBlock.pos, textBlock.pos + textBlock.node.nodeSize, undefined, ' ');
52
+ linkifyjs.find(text)
53
+ .filter(link => link.isLink)
54
+ .filter(link => {
55
+ if (options.validate) {
56
+ return options.validate(link.value);
57
+ }
58
+ return true;
59
+ })
60
+ // calculate link position
61
+ .map(link => ({
62
+ ...link,
63
+ from: textBlock.pos + link.start + 1,
64
+ to: textBlock.pos + link.end + 1,
65
+ }))
66
+ // check if link is within the changed range
67
+ .filter(link => {
68
+ const fromIsInRange = newRange.from >= link.from && newRange.from <= link.to;
69
+ const toIsInRange = newRange.to >= link.from && newRange.to <= link.to;
70
+ return fromIsInRange || toIsInRange;
71
+ })
72
+ // add link mark
73
+ .forEach(link => {
74
+ tr.addMark(link.from, link.to, options.type.create({
75
+ href: link.href,
76
+ }));
77
+ });
78
+ });
79
+ });
80
+ if (!tr.steps.length) {
81
+ return;
82
+ }
83
+ return tr;
84
+ },
85
+ });
86
+ }
87
+
88
+ function clickHandler(options) {
89
+ return new prosemirrorState.Plugin({
90
+ key: new prosemirrorState.PluginKey('handleClickLink'),
91
+ props: {
92
+ handleClick: (view, pos, event) => {
93
+ var _a;
94
+ const attrs = core.getAttributes(view.state, options.type.name);
95
+ const link = (_a = event.target) === null || _a === void 0 ? void 0 : _a.closest('a');
96
+ if (link && attrs.href) {
97
+ window.open(attrs.href, attrs.target);
98
+ return true;
99
+ }
100
+ return false;
101
+ },
102
+ },
103
+ });
104
+ }
105
+
106
+ function pasteHandler(options) {
107
+ return new prosemirrorState.Plugin({
108
+ key: new prosemirrorState.PluginKey('handlePasteLink'),
109
+ props: {
110
+ handlePaste: (view, event, slice) => {
111
+ const { state } = view;
112
+ const { selection } = state;
113
+ const { empty } = selection;
114
+ if (empty) {
115
+ return false;
116
+ }
117
+ let textContent = '';
118
+ slice.content.forEach(node => {
119
+ textContent += node.textContent;
120
+ });
121
+ const link = linkifyjs.find(textContent).find(item => item.isLink && item.value === textContent);
122
+ if (!textContent || !link) {
123
+ return false;
124
+ }
125
+ options.editor.commands.setMark(options.type, {
126
+ href: link.href,
127
+ });
128
+ return true;
129
+ },
130
+ },
131
+ });
132
+ }
133
+
16
134
  const Link = core.Mark.create({
17
135
  name: 'link',
18
136
  priority: 1000,
19
- inclusive: false,
20
- defaultOptions: {
21
- openOnClick: true,
22
- linkOnPaste: true,
23
- HTMLAttributes: {
24
- target: '_blank',
25
- rel: 'noopener noreferrer nofollow',
26
- },
137
+ keepOnSplit: false,
138
+ onCreate() {
139
+ this.options.protocols.forEach(linkifyjs.registerCustomProtocol);
140
+ },
141
+ inclusive() {
142
+ return this.options.autolink;
143
+ },
144
+ addOptions() {
145
+ return {
146
+ openOnClick: true,
147
+ linkOnPaste: true,
148
+ autolink: true,
149
+ protocols: [],
150
+ HTMLAttributes: {
151
+ target: '_blank',
152
+ rel: 'noopener noreferrer nofollow',
153
+ class: null,
154
+ },
155
+ validate: undefined,
156
+ };
27
157
  },
28
158
  addAttributes() {
29
159
  return {
@@ -33,77 +163,88 @@ const Link = core.Mark.create({
33
163
  target: {
34
164
  default: this.options.HTMLAttributes.target,
35
165
  },
166
+ class: {
167
+ default: this.options.HTMLAttributes.class,
168
+ },
36
169
  };
37
170
  },
38
171
  parseHTML() {
39
172
  return [
40
- { tag: 'a[href]' },
173
+ { tag: 'a[href]:not([href *= "javascript:" i])' },
41
174
  ];
42
175
  },
43
176
  renderHTML({ HTMLAttributes }) {
44
- return ['a', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
177
+ return [
178
+ 'a',
179
+ core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
180
+ 0,
181
+ ];
45
182
  },
46
183
  addCommands() {
47
184
  return {
48
- setLink: attributes => ({ commands }) => {
49
- return commands.setMark('link', attributes);
185
+ setLink: attributes => ({ chain }) => {
186
+ return chain()
187
+ .setMark(this.name, attributes)
188
+ .setMeta('preventAutolink', true)
189
+ .run();
50
190
  },
51
- toggleLink: attributes => ({ commands }) => {
52
- return commands.toggleMark('link', attributes);
191
+ toggleLink: attributes => ({ chain }) => {
192
+ return chain()
193
+ .toggleMark(this.name, attributes, { extendEmptyMarkRange: true })
194
+ .setMeta('preventAutolink', true)
195
+ .run();
53
196
  },
54
- unsetLink: () => ({ commands }) => {
55
- return commands.unsetMark('link');
197
+ unsetLink: () => ({ chain }) => {
198
+ return chain()
199
+ .unsetMark(this.name, { extendEmptyMarkRange: true })
200
+ .setMeta('preventAutolink', true)
201
+ .run();
56
202
  },
57
203
  };
58
204
  },
59
205
  addPasteRules() {
60
206
  return [
61
- core.markPasteRule(pasteRegex, this.type, match => ({ href: match[0] })),
207
+ core.markPasteRule({
208
+ find: text => linkifyjs.find(text)
209
+ .filter(link => {
210
+ if (this.options.validate) {
211
+ return this.options.validate(link.value);
212
+ }
213
+ return true;
214
+ })
215
+ .filter(link => link.isLink)
216
+ .map(link => ({
217
+ text: link.value,
218
+ index: link.start,
219
+ data: link,
220
+ })),
221
+ type: this.type,
222
+ getAttributes: match => {
223
+ var _a;
224
+ return ({
225
+ href: (_a = match.data) === null || _a === void 0 ? void 0 : _a.href,
226
+ });
227
+ },
228
+ }),
62
229
  ];
63
230
  },
64
231
  addProseMirrorPlugins() {
65
232
  const plugins = [];
233
+ if (this.options.autolink) {
234
+ plugins.push(autolink({
235
+ type: this.type,
236
+ validate: this.options.validate,
237
+ }));
238
+ }
66
239
  if (this.options.openOnClick) {
67
- plugins.push(new prosemirrorState.Plugin({
68
- key: new prosemirrorState.PluginKey('handleClickLink'),
69
- props: {
70
- handleClick: (view, pos, event) => {
71
- var _a;
72
- const attrs = this.editor.getAttributes('link');
73
- const link = (_a = event.target) === null || _a === void 0 ? void 0 : _a.closest('a');
74
- if (link && attrs.href) {
75
- window.open(attrs.href, attrs.target);
76
- return true;
77
- }
78
- return false;
79
- },
80
- },
240
+ plugins.push(clickHandler({
241
+ type: this.type,
81
242
  }));
82
243
  }
83
244
  if (this.options.linkOnPaste) {
84
- plugins.push(new prosemirrorState.Plugin({
85
- key: new prosemirrorState.PluginKey('handlePasteLink'),
86
- props: {
87
- handlePaste: (view, event, slice) => {
88
- const { state } = view;
89
- const { selection } = state;
90
- const { empty } = selection;
91
- if (empty) {
92
- return false;
93
- }
94
- let textContent = '';
95
- slice.content.forEach(node => {
96
- textContent += node.textContent;
97
- });
98
- if (!textContent || !textContent.match(pasteRegexExact)) {
99
- return false;
100
- }
101
- this.editor.commands.setMark(this.type, {
102
- href: textContent,
103
- });
104
- return true;
105
- },
106
- },
245
+ plugins.push(pasteHandler({
246
+ editor: this.editor,
247
+ type: this.type,
107
248
  }));
108
249
  }
109
250
  return plugins;
@@ -111,7 +252,5 @@ const Link = core.Mark.create({
111
252
  });
112
253
 
113
254
  exports.Link = Link;
114
- exports.default = Link;
115
- exports.pasteRegex = pasteRegex;
116
- exports.pasteRegexExact = pasteRegexExact;
255
+ exports["default"] = Link;
117
256
  //# sourceMappingURL=tiptap-extension-link.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap-extension-link.cjs.js","sources":["../src/link.ts"],"sourcesContent":["import {\n Mark,\n markPasteRule,\n mergeAttributes,\n} from '@tiptap/core'\nimport { Plugin, PluginKey } from 'prosemirror-state'\n\nexport interface LinkOptions {\n /**\n * If enabled, links will be opened on click.\n */\n openOnClick: boolean,\n /**\n * Adds a link to the current selection if the pasted content only contains an url.\n */\n linkOnPaste: boolean,\n /**\n * A list of HTML attributes to be rendered.\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n link: {\n /**\n * Set a link mark\n */\n setLink: (attributes: { href: string, target?: string }) => ReturnType,\n /**\n * Toggle a link mark\n */\n toggleLink: (attributes: { href: string, target?: string }) => ReturnType,\n /**\n * Unset a link mark\n */\n unsetLink: () => ReturnType,\n }\n }\n}\n\n/**\n * A regex that matches any string that contains a link\n */\nexport const pasteRegex = /https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z]{2,}\\b(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)/gi\n\n/**\n * A regex that matches an url\n */\nexport const pasteRegexExact = /^https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z]{2,}\\b(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)$/gi\n\nexport const Link = Mark.create<LinkOptions>({\n name: 'link',\n\n priority: 1000,\n\n inclusive: false,\n\n defaultOptions: {\n openOnClick: true,\n linkOnPaste: true,\n HTMLAttributes: {\n target: '_blank',\n rel: 'noopener noreferrer nofollow',\n },\n },\n\n addAttributes() {\n return {\n href: {\n default: null,\n },\n target: {\n default: this.options.HTMLAttributes.target,\n },\n }\n },\n\n parseHTML() {\n return [\n { tag: 'a[href]' },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['a', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n setLink: attributes => ({ commands }) => {\n return commands.setMark('link', attributes)\n },\n toggleLink: attributes => ({ commands }) => {\n return commands.toggleMark('link', attributes)\n },\n unsetLink: () => ({ commands }) => {\n return commands.unsetMark('link')\n },\n }\n },\n\n addPasteRules() {\n return [\n markPasteRule(pasteRegex, this.type, match => ({ href: match[0] })),\n ]\n },\n\n addProseMirrorPlugins() {\n const plugins = []\n\n if (this.options.openOnClick) {\n plugins.push(\n new Plugin({\n key: new PluginKey('handleClickLink'),\n props: {\n handleClick: (view, pos, event) => {\n const attrs = this.editor.getAttributes('link')\n const link = (event.target as HTMLElement)?.closest('a')\n\n if (link && attrs.href) {\n window.open(attrs.href, attrs.target)\n\n return true\n }\n\n return false\n },\n },\n }),\n )\n }\n\n if (this.options.linkOnPaste) {\n plugins.push(\n new Plugin({\n key: new PluginKey('handlePasteLink'),\n props: {\n handlePaste: (view, event, slice) => {\n const { state } = view\n const { selection } = state\n const { empty } = selection\n\n if (empty) {\n return false\n }\n\n let textContent = ''\n\n slice.content.forEach(node => {\n textContent += node.textContent\n })\n\n if (!textContent || !textContent.match(pasteRegexExact)) {\n return false\n }\n\n this.editor.commands.setMark(this.type, {\n href: textContent,\n })\n\n return true\n },\n },\n }),\n )\n }\n\n return plugins\n },\n})\n"],"names":["Mark","mergeAttributes","markPasteRule","Plugin","PluginKey"],"mappings":";;;;;;;AAyCA;;;MAGa,UAAU,GAAG,kIAAiI;AAE3J;;;MAGa,eAAe,GAAG,oIAAmI;MAErJ,IAAI,GAAGA,SAAI,CAAC,MAAM,CAAc;IAC3C,IAAI,EAAE,MAAM;IAEZ,QAAQ,EAAE,IAAI;IAEd,SAAS,EAAE,KAAK;IAEhB,cAAc,EAAE;QACd,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE;YACd,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,8BAA8B;SACpC;KACF;IAED,aAAa;QACX,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AAI,CAAA;qBACZ;iBACF;aACF,CAAC,CACH,CAAA;SACF;QAED,OAAO,OAAO,CAAA;KACf;CACF;;;;;;;"}
1
+ {"version":3,"file":"tiptap-extension-link.cjs.js","sources":["../src/helpers/autolink.ts","../src/helpers/clickHandler.ts","../src/helpers/pasteHandler.ts","../src/link.ts"],"sourcesContent":["import {\n combineTransactionSteps,\n findChildrenInRange,\n getChangedRanges,\n getMarksBetween,\n} from '@tiptap/core'\nimport { find, test } from 'linkifyjs'\nimport { MarkType } from 'prosemirror-model'\nimport { Plugin, PluginKey } from 'prosemirror-state'\n\ntype AutolinkOptions = {\n type: MarkType,\n validate?: (url: string) => boolean,\n}\n\nexport function autolink(options: AutolinkOptions): Plugin {\n return new Plugin({\n key: new PluginKey('autolink'),\n appendTransaction: (transactions, oldState, newState) => {\n const docChanges = transactions.some(transaction => transaction.docChanged)\n && !oldState.doc.eq(newState.doc)\n const preventAutolink = transactions.some(transaction => transaction.getMeta('preventAutolink'))\n\n if (!docChanges || preventAutolink) {\n return\n }\n\n const { tr } = newState\n const transform = combineTransactionSteps(oldState.doc, [...transactions])\n const { mapping } = transform\n const changes = getChangedRanges(transform)\n\n changes.forEach(({ oldRange, newRange }) => {\n // at first we check if we have to remove links\n getMarksBetween(oldRange.from, oldRange.to, oldState.doc)\n .filter(item => item.mark.type === options.type)\n .forEach(oldMark => {\n const newFrom = mapping.map(oldMark.from)\n const newTo = mapping.map(oldMark.to)\n const newMarks = getMarksBetween(newFrom, newTo, newState.doc)\n .filter(item => item.mark.type === options.type)\n\n if (!newMarks.length) {\n return\n }\n\n const newMark = newMarks[0]\n const oldLinkText = oldState.doc.textBetween(oldMark.from, oldMark.to, undefined, ' ')\n const newLinkText = newState.doc.textBetween(newMark.from, newMark.to, undefined, ' ')\n const wasLink = test(oldLinkText)\n const isLink = test(newLinkText)\n\n // remove only the link, if it was a link before too\n // because we don’t want to remove links that were set manually\n if (wasLink && !isLink) {\n tr.removeMark(newMark.from, newMark.to, options.type)\n }\n })\n\n // now let’s see if we can add new links\n findChildrenInRange(newState.doc, newRange, node => node.isTextblock)\n .forEach(textBlock => {\n // we need to define a placeholder for leaf nodes\n // so that the link position can be calculated correctly\n const text = newState.doc.textBetween(\n textBlock.pos,\n textBlock.pos + textBlock.node.nodeSize,\n undefined,\n ' ',\n )\n\n find(text)\n .filter(link => link.isLink)\n .filter(link => {\n if (options.validate) {\n return options.validate(link.value)\n }\n\n return true\n })\n // calculate link position\n .map(link => ({\n ...link,\n from: textBlock.pos + link.start + 1,\n to: textBlock.pos + link.end + 1,\n }))\n // check if link is within the changed range\n .filter(link => {\n const fromIsInRange = newRange.from >= link.from && newRange.from <= link.to\n const toIsInRange = newRange.to >= link.from && newRange.to <= link.to\n\n return fromIsInRange || toIsInRange\n })\n // add link mark\n .forEach(link => {\n tr.addMark(link.from, link.to, options.type.create({\n href: link.href,\n }))\n })\n })\n })\n\n if (!tr.steps.length) {\n return\n }\n\n return tr\n },\n })\n}\n","import { getAttributes } from '@tiptap/core'\nimport { MarkType } from 'prosemirror-model'\nimport { Plugin, PluginKey } from 'prosemirror-state'\n\ntype ClickHandlerOptions = {\n type: MarkType,\n}\n\nexport function clickHandler(options: ClickHandlerOptions): Plugin {\n return new Plugin({\n key: new PluginKey('handleClickLink'),\n props: {\n handleClick: (view, pos, event) => {\n const attrs = getAttributes(view.state, options.type.name)\n const link = (event.target as HTMLElement)?.closest('a')\n\n if (link && attrs.href) {\n window.open(attrs.href, attrs.target)\n\n return true\n }\n\n return false\n },\n },\n })\n}\n","import { Editor } from '@tiptap/core'\nimport { find } from 'linkifyjs'\nimport { MarkType } from 'prosemirror-model'\nimport { Plugin, PluginKey } from 'prosemirror-state'\n\ntype PasteHandlerOptions = {\n editor: Editor,\n type: MarkType,\n}\n\nexport function pasteHandler(options: PasteHandlerOptions): Plugin {\n return new Plugin({\n key: new PluginKey('handlePasteLink'),\n props: {\n handlePaste: (view, event, slice) => {\n const { state } = view\n const { selection } = state\n const { empty } = selection\n\n if (empty) {\n return false\n }\n\n let textContent = ''\n\n slice.content.forEach(node => {\n textContent += node.textContent\n })\n\n const link = find(textContent).find(item => item.isLink && item.value === textContent)\n\n if (!textContent || !link) {\n return false\n }\n\n options.editor.commands.setMark(options.type, {\n href: link.href,\n })\n\n return true\n },\n },\n })\n}\n","import { Mark, markPasteRule, mergeAttributes } from '@tiptap/core'\nimport { find, registerCustomProtocol } from 'linkifyjs'\n\nimport { autolink } from './helpers/autolink'\nimport { clickHandler } from './helpers/clickHandler'\nimport { pasteHandler } from './helpers/pasteHandler'\n\nexport interface LinkOptions {\n /**\n * If enabled, it adds links as you type.\n */\n autolink: boolean,\n /**\n * An array of custom protocols to be registered with linkifyjs.\n */\n protocols: Array<string>,\n /**\n * If enabled, links will be opened on click.\n */\n openOnClick: boolean,\n /**\n * Adds a link to the current selection if the pasted content only contains an url.\n */\n linkOnPaste: boolean,\n /**\n * A list of HTML attributes to be rendered.\n */\n HTMLAttributes: Record<string, any>,\n /**\n * A validation function that modifies link verification for the auto linker.\n * @param url - The url to be validated.\n * @returns - True if the url is valid, false otherwise.\n */\n validate?: (url: string) => boolean,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n link: {\n /**\n * Set a link mark\n */\n setLink: (attributes: { href: string, target?: string }) => ReturnType,\n /**\n * Toggle a link mark\n */\n toggleLink: (attributes: { href: string, target?: string }) => ReturnType,\n /**\n * Unset a link mark\n */\n unsetLink: () => ReturnType,\n }\n }\n}\n\nexport const Link = Mark.create<LinkOptions>({\n name: 'link',\n\n priority: 1000,\n\n keepOnSplit: false,\n\n onCreate() {\n this.options.protocols.forEach(registerCustomProtocol)\n },\n\n inclusive() {\n return this.options.autolink\n },\n\n addOptions() {\n return {\n openOnClick: true,\n linkOnPaste: true,\n autolink: true,\n protocols: [],\n HTMLAttributes: {\n target: '_blank',\n rel: 'noopener noreferrer nofollow',\n class: null,\n },\n validate: undefined,\n }\n },\n\n addAttributes() {\n return {\n href: {\n default: null,\n },\n target: {\n default: this.options.HTMLAttributes.target,\n },\n class: {\n default: this.options.HTMLAttributes.class,\n },\n }\n },\n\n parseHTML() {\n return [\n { tag: 'a[href]:not([href *= \"javascript:\" i])' },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n 'a',\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ]\n },\n\n addCommands() {\n return {\n setLink: attributes => ({ chain }) => {\n return chain()\n .setMark(this.name, attributes)\n .setMeta('preventAutolink', true)\n .run()\n },\n\n toggleLink: attributes => ({ chain }) => {\n return chain()\n .toggleMark(this.name, attributes, { extendEmptyMarkRange: true })\n .setMeta('preventAutolink', true)\n .run()\n },\n\n unsetLink: () => ({ chain }) => {\n return chain()\n .unsetMark(this.name, { extendEmptyMarkRange: true })\n .setMeta('preventAutolink', true)\n .run()\n },\n }\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: text => find(text)\n .filter(link => {\n if (this.options.validate) {\n return this.options.validate(link.value)\n }\n\n return true\n })\n .filter(link => link.isLink)\n .map(link => ({\n text: link.value,\n index: link.start,\n data: link,\n })),\n type: this.type,\n getAttributes: match => ({\n href: match.data?.href,\n }),\n }),\n ]\n },\n\n addProseMirrorPlugins() {\n const plugins = []\n\n if (this.options.autolink) {\n plugins.push(autolink({\n type: this.type,\n validate: this.options.validate,\n }))\n }\n\n if (this.options.openOnClick) {\n plugins.push(clickHandler({\n type: this.type,\n }))\n }\n\n if (this.options.linkOnPaste) {\n plugins.push(pasteHandler({\n editor: this.editor,\n type: this.type,\n }))\n }\n\n return plugins\n },\n})\n"],"names":["Plugin","PluginKey","combineTransactionSteps","getChangedRanges","getMarksBetween","test","findChildrenInRange","find","getAttributes","Mark","registerCustomProtocol","mergeAttributes","markPasteRule"],"mappings":";;;;;;;;AAeM,SAAU,QAAQ,CAAC,OAAwB,EAAA;IAC/C,OAAO,IAAIA,uBAAM,CAAC;AAChB,QAAA,GAAG,EAAE,IAAIC,0BAAS,CAAC,UAAU,CAA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