Skip to content

Commit

Permalink
fix: performance tiptap link issue (#1628)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Dec 23, 2024
1 parent 9295c2d commit b310930
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions projects/editor/extensions/link/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import {
tuiParseNodeAttributes,
} from '@taiga-ui/editor/utils';
import type {KeyboardShortcutCommand} from '@tiptap/core';
import {markPasteRule} from '@tiptap/core';
import {Link} from '@tiptap/extension-link';
import {find} from 'linkifyjs';

export const TuiLink = Link.extend({
addAttributes() {
Expand Down Expand Up @@ -64,19 +62,7 @@ export const TuiLink = Link.extend({

addPasteRules() {
return [
markPasteRule({
find: (text) =>
find(text)
.filter((link) => this.options.validate?.(link.value) ?? true)
.filter((link) => link.isLink)
.map((link) => ({
text: link.value,
index: link.start,
data: link,
})),
type: this.type,
getAttributes: (match) => ({href: match.data?.href}),
}),
// Workaround for issue: https://github.com/ueberdosis/tiptap/issues/5957
];
},
}).configure({openOnClick: false});

0 comments on commit b310930

Please sign in to comment.