@tiptap/extension-link 2.0.0-beta.20 → 2.0.0-beta.201
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.
- package/dist/packages/extension-link/src/helpers/autolink.d.ts +8 -0
- package/dist/packages/extension-link/src/helpers/clickHandler.d.ts +7 -0
- package/dist/packages/extension-link/src/helpers/pasteHandler.d.ts +9 -0
- package/dist/packages/extension-link/src/link.d.ts +15 -9
- package/dist/tiptap-extension-link.cjs.js +220 -65
- package/dist/tiptap-extension-link.cjs.js.map +1 -1
- package/dist/tiptap-extension-link.esm.js +221 -64
- package/dist/tiptap-extension-link.esm.js.map +1 -1
- package/dist/tiptap-extension-link.umd.js +224 -70
- package/dist/tiptap-extension-link.umd.js.map +1 -1
- package/package.json +6 -5
- package/src/helpers/autolink.ts +134 -0
- package/src/helpers/clickHandler.ts +27 -0
- package/src/helpers/pasteHandler.ts +44 -0
- package/src/link.ts +108 -85
- package/CHANGELOG.md +0 -292
- package/LICENSE.md +0 -21
|
@@ -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,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,173 @@
|
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
const nodesInChangedRanges = core.findChildrenInRange(newState.doc, newRange, node => node.isTextblock);
|
|
48
|
+
let textBlock;
|
|
49
|
+
let textBeforeWhitespace;
|
|
50
|
+
if (nodesInChangedRanges.length > 1) {
|
|
51
|
+
// Grab the first node within the changed ranges (ex. the first of two paragraphs when hitting enter)
|
|
52
|
+
textBlock = nodesInChangedRanges[0];
|
|
53
|
+
textBeforeWhitespace = newState.doc.textBetween(textBlock.pos, textBlock.pos + textBlock.node.nodeSize, undefined, ' ');
|
|
54
|
+
}
|
|
55
|
+
else if (nodesInChangedRanges.length
|
|
56
|
+
// We want to make sure to include the block seperator argument to treat hard breaks like spaces
|
|
57
|
+
&& newState.doc.textBetween(newRange.from, newRange.to, ' ', ' ').endsWith(' ')) {
|
|
58
|
+
textBlock = nodesInChangedRanges[0];
|
|
59
|
+
textBeforeWhitespace = newState.doc.textBetween(textBlock.pos, newRange.to, undefined, ' ');
|
|
60
|
+
}
|
|
61
|
+
if (textBlock && textBeforeWhitespace) {
|
|
62
|
+
const wordsBeforeWhitespace = textBeforeWhitespace.split(' ').filter(s => s !== '');
|
|
63
|
+
if (wordsBeforeWhitespace.length <= 0) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
const lastWordBeforeSpace = wordsBeforeWhitespace[wordsBeforeWhitespace.length - 1];
|
|
67
|
+
const lastWordAndBlockOffset = textBlock.pos + textBeforeWhitespace.lastIndexOf(lastWordBeforeSpace);
|
|
68
|
+
if (!lastWordBeforeSpace) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
linkifyjs.find(lastWordBeforeSpace)
|
|
72
|
+
.filter(link => link.isLink)
|
|
73
|
+
.filter(link => {
|
|
74
|
+
if (options.validate) {
|
|
75
|
+
return options.validate(link.value);
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
})
|
|
79
|
+
// calculate link position
|
|
80
|
+
.map(link => ({
|
|
81
|
+
...link,
|
|
82
|
+
from: lastWordAndBlockOffset + link.start + 1,
|
|
83
|
+
to: lastWordAndBlockOffset + link.end + 1,
|
|
84
|
+
}))
|
|
85
|
+
// add link mark
|
|
86
|
+
.forEach(link => {
|
|
87
|
+
tr.addMark(link.from, link.to, options.type.create({
|
|
88
|
+
href: link.href,
|
|
89
|
+
}));
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
if (!tr.steps.length) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
return tr;
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function clickHandler(options) {
|
|
102
|
+
return new prosemirrorState.Plugin({
|
|
103
|
+
key: new prosemirrorState.PluginKey('handleClickLink'),
|
|
104
|
+
props: {
|
|
105
|
+
handleClick: (view, pos, event) => {
|
|
106
|
+
var _a;
|
|
107
|
+
const attrs = core.getAttributes(view.state, options.type.name);
|
|
108
|
+
const link = (_a = event.target) === null || _a === void 0 ? void 0 : _a.closest('a');
|
|
109
|
+
if (link && attrs.href) {
|
|
110
|
+
window.open(attrs.href, attrs.target);
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function pasteHandler(options) {
|
|
120
|
+
return new prosemirrorState.Plugin({
|
|
121
|
+
key: new prosemirrorState.PluginKey('handlePasteLink'),
|
|
122
|
+
props: {
|
|
123
|
+
handlePaste: (view, event, slice) => {
|
|
124
|
+
const { state } = view;
|
|
125
|
+
const { selection } = state;
|
|
126
|
+
const { empty } = selection;
|
|
127
|
+
if (empty) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
let textContent = '';
|
|
131
|
+
slice.content.forEach(node => {
|
|
132
|
+
textContent += node.textContent;
|
|
133
|
+
});
|
|
134
|
+
const link = linkifyjs.find(textContent).find(item => item.isLink && item.value === textContent);
|
|
135
|
+
if (!textContent || !link) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
options.editor.commands.setMark(options.type, {
|
|
139
|
+
href: link.href,
|
|
140
|
+
});
|
|
141
|
+
return true;
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
16
147
|
const Link = core.Mark.create({
|
|
17
148
|
name: 'link',
|
|
18
149
|
priority: 1000,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
150
|
+
keepOnSplit: false,
|
|
151
|
+
onCreate() {
|
|
152
|
+
this.options.protocols.forEach(linkifyjs.registerCustomProtocol);
|
|
153
|
+
},
|
|
154
|
+
onDestroy() {
|
|
155
|
+
linkifyjs.reset();
|
|
156
|
+
},
|
|
157
|
+
inclusive() {
|
|
158
|
+
return this.options.autolink;
|
|
159
|
+
},
|
|
160
|
+
addOptions() {
|
|
161
|
+
return {
|
|
162
|
+
openOnClick: true,
|
|
163
|
+
linkOnPaste: true,
|
|
164
|
+
autolink: true,
|
|
165
|
+
protocols: [],
|
|
166
|
+
HTMLAttributes: {
|
|
167
|
+
target: '_blank',
|
|
168
|
+
rel: 'noopener noreferrer nofollow',
|
|
169
|
+
class: null,
|
|
170
|
+
},
|
|
171
|
+
validate: undefined,
|
|
172
|
+
};
|
|
27
173
|
},
|
|
28
174
|
addAttributes() {
|
|
29
175
|
return {
|
|
@@ -33,77 +179,88 @@ const Link = core.Mark.create({
|
|
|
33
179
|
target: {
|
|
34
180
|
default: this.options.HTMLAttributes.target,
|
|
35
181
|
},
|
|
182
|
+
class: {
|
|
183
|
+
default: this.options.HTMLAttributes.class,
|
|
184
|
+
},
|
|
36
185
|
};
|
|
37
186
|
},
|
|
38
187
|
parseHTML() {
|
|
39
188
|
return [
|
|
40
|
-
{ tag: 'a[href]' },
|
|
189
|
+
{ tag: 'a[href]:not([href *= "javascript:" i])' },
|
|
41
190
|
];
|
|
42
191
|
},
|
|
43
192
|
renderHTML({ HTMLAttributes }) {
|
|
44
|
-
return [
|
|
193
|
+
return [
|
|
194
|
+
'a',
|
|
195
|
+
core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
196
|
+
0,
|
|
197
|
+
];
|
|
45
198
|
},
|
|
46
199
|
addCommands() {
|
|
47
200
|
return {
|
|
48
|
-
setLink: attributes => ({
|
|
49
|
-
return
|
|
201
|
+
setLink: attributes => ({ chain }) => {
|
|
202
|
+
return chain()
|
|
203
|
+
.setMark(this.name, attributes)
|
|
204
|
+
.setMeta('preventAutolink', true)
|
|
205
|
+
.run();
|
|
50
206
|
},
|
|
51
|
-
toggleLink: attributes => ({
|
|
52
|
-
return
|
|
207
|
+
toggleLink: attributes => ({ chain }) => {
|
|
208
|
+
return chain()
|
|
209
|
+
.toggleMark(this.name, attributes, { extendEmptyMarkRange: true })
|
|
210
|
+
.setMeta('preventAutolink', true)
|
|
211
|
+
.run();
|
|
53
212
|
},
|
|
54
|
-
unsetLink: () => ({
|
|
55
|
-
return
|
|
213
|
+
unsetLink: () => ({ chain }) => {
|
|
214
|
+
return chain()
|
|
215
|
+
.unsetMark(this.name, { extendEmptyMarkRange: true })
|
|
216
|
+
.setMeta('preventAutolink', true)
|
|
217
|
+
.run();
|
|
56
218
|
},
|
|
57
219
|
};
|
|
58
220
|
},
|
|
59
221
|
addPasteRules() {
|
|
60
222
|
return [
|
|
61
|
-
core.markPasteRule(
|
|
223
|
+
core.markPasteRule({
|
|
224
|
+
find: text => linkifyjs.find(text)
|
|
225
|
+
.filter(link => {
|
|
226
|
+
if (this.options.validate) {
|
|
227
|
+
return this.options.validate(link.value);
|
|
228
|
+
}
|
|
229
|
+
return true;
|
|
230
|
+
})
|
|
231
|
+
.filter(link => link.isLink)
|
|
232
|
+
.map(link => ({
|
|
233
|
+
text: link.value,
|
|
234
|
+
index: link.start,
|
|
235
|
+
data: link,
|
|
236
|
+
})),
|
|
237
|
+
type: this.type,
|
|
238
|
+
getAttributes: match => {
|
|
239
|
+
var _a;
|
|
240
|
+
return ({
|
|
241
|
+
href: (_a = match.data) === null || _a === void 0 ? void 0 : _a.href,
|
|
242
|
+
});
|
|
243
|
+
},
|
|
244
|
+
}),
|
|
62
245
|
];
|
|
63
246
|
},
|
|
64
247
|
addProseMirrorPlugins() {
|
|
65
248
|
const plugins = [];
|
|
249
|
+
if (this.options.autolink) {
|
|
250
|
+
plugins.push(autolink({
|
|
251
|
+
type: this.type,
|
|
252
|
+
validate: this.options.validate,
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
66
255
|
if (this.options.openOnClick) {
|
|
67
|
-
plugins.push(
|
|
68
|
-
|
|
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
|
-
},
|
|
256
|
+
plugins.push(clickHandler({
|
|
257
|
+
type: this.type,
|
|
81
258
|
}));
|
|
82
259
|
}
|
|
83
260
|
if (this.options.linkOnPaste) {
|
|
84
|
-
plugins.push(
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
},
|
|
261
|
+
plugins.push(pasteHandler({
|
|
262
|
+
editor: this.editor,
|
|
263
|
+
type: this.type,
|
|
107
264
|
}));
|
|
108
265
|
}
|
|
109
266
|
return plugins;
|
|
@@ -111,7 +268,5 @@ const Link = core.Mark.create({
|
|
|
111
268
|
});
|
|
112
269
|
|
|
113
270
|
exports.Link = Link;
|
|
114
|
-
exports[
|
|
115
|
-
exports.pasteRegex = pasteRegex;
|
|
116
|
-
exports.pasteRegexExact = pasteRegexExact;
|
|
271
|
+
exports["default"] = Link;
|
|
117
272
|
//# 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, { extendEmptyMarkRange: true })\n },\n unsetLink: () => ({ commands }) => {\n return commands.unsetMark('link', { extendEmptyMarkRange: true })\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,OAAO;YACL,IAAI,EAAE;gBACJ,OAAO,EAAE,IAAI;aACd;YACD,MAAM,EAAE;gBACN,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM;aAC5C;SACF,CAAA;KACF;IAED,SAAS;QACP,OAAO;YACL,EAAE,GAAG,EAAE,SAAS,EAAE;SACnB,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE;QAC3B,OAAO,CAAC,GAAG,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;KAC9E;IAED,WAAW;QACT,OAAO;YACL,OAAO,EAAE,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE;gBAClC,OAAO,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;aAC5C;YACD,UAAU,EAAE,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE;gBACrC,OAAO,QAAQ,CAAC,UAAU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,CAAC;gBACrC,KAAK,EAAE;oBACL,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK;wBAC9B,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;wBACtB,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAA;wBAC3B,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAA;wBAE3B,IAAI,KAAK,EAAE;4BACT,OAAO,KAAK,CAAA;yBACb;wBAED,IAAI,WAAW,GAAG,EAAE,CAAA;wBAEpB,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI;4BACxB,WAAW,IAAI,IAAI,CAAC,WAAW,CAAA;yBAChC,CAAC,CAAA;wBAEF,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE;4BACvD,OAAO,KAAK,CAAA;yBACb;wBAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE;4BACtC,IAAI,EAAE,WAAW;yBAClB,CAAC,CAAA;wBAEF,OAAO,IAAI,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 NodeWithPos,\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 const nodesInChangedRanges = findChildrenInRange(newState.doc, newRange, node => node.isTextblock)\n\n let textBlock: NodeWithPos | undefined\n let textBeforeWhitespace: string | undefined\n\n if (nodesInChangedRanges.length > 1) {\n // Grab the first node within the changed ranges (ex. the first of two paragraphs when hitting enter)\n textBlock = nodesInChangedRanges[0]\n textBeforeWhitespace = newState.doc.textBetween(\n textBlock.pos,\n textBlock.pos + textBlock.node.nodeSize,\n undefined,\n ' ',\n )\n } else if (\n nodesInChangedRanges.length\n // We want to make sure to include the block seperator argument to treat hard breaks like spaces\n && newState.doc.textBetween(newRange.from, newRange.to, ' ', ' ').endsWith(' ')\n ) {\n textBlock = nodesInChangedRanges[0]\n textBeforeWhitespace = newState.doc.textBetween(\n textBlock.pos,\n newRange.to,\n undefined,\n ' ',\n )\n }\n\n if (textBlock && textBeforeWhitespace) {\n const wordsBeforeWhitespace = textBeforeWhitespace.split(' ').filter(s => s !== '')\n\n if (wordsBeforeWhitespace.length <= 0) {\n return false\n }\n\n const lastWordBeforeSpace = wordsBeforeWhitespace[wordsBeforeWhitespace.length - 1]\n const lastWordAndBlockOffset = textBlock.pos + textBeforeWhitespace.lastIndexOf(lastWordBeforeSpace)\n\n if (!lastWordBeforeSpace) {\n return false\n }\n\n find(lastWordBeforeSpace)\n .filter(link => link.isLink)\n .filter(link => {\n if (options.validate) {\n return options.validate(link.value)\n }\n return true\n })\n // calculate link position\n .map(link => ({\n ...link,\n from: lastWordAndBlockOffset + link.start + 1,\n to: lastWordAndBlockOffset + link.end + 1,\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, reset } from 'linkifyjs'\nimport { Plugin } from 'prosemirror-state'\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 onDestroy() {\n reset()\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: Plugin[] = []\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","reset","mergeAttributes","markPasteRule"],"mappings":";;;;;;;;AAgBM,SAAU,QAAQ,CAAC,OAAwB,EAAA;IAC/C,OAAO,IAAIA,uBAAM,CAAC;AAChB,QAAA,GAAG,EAAE,I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