Skip to content

Commit

Permalink
fix: remove non-ASCII characters on linkify pasted content
Browse files Browse the repository at this point in the history
  • Loading branch information
robertu7 committed Jun 13, 2024
1 parent dfd3b07 commit 7f4649a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@matters/matters-editor",
"version": "0.2.5-alpha.4",
"version": "0.2.5-alpha.5",
"description": "Editor for matters.news",
"author": "https://github.com/thematters",
"homepage": "https://github.com/thematters/matters-editor",
Expand Down
11 changes: 6 additions & 5 deletions src/editors/extensions/link/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
import { Plugin } from '@tiptap/pm/state'
import { find, registerCustomProtocol, reset } from 'linkifyjs'

import { autolink } from './helpers/autolink.js'
import { clickHandler } from './helpers/clickHandler.js'
import { pasteHandler } from './helpers/pasteHandler.js'
import { autolink } from './helpers/autolink'
import { clickHandler } from './helpers/clickHandler'
import { pasteHandler } from './helpers/pasteHandler'

/**
* Link extension compitable with the Mention extension, forked from:
Expand Down Expand Up @@ -284,9 +284,10 @@ export const Link = Mark.create<LinkOptions>({
if (links.length) {
links.forEach((link) =>
foundLinks.push({
text: link.value,
// remove non-ASCII characters
text: link.value.replace(/[^ -~]/g, ''),
data: {
href: link.href,
href: link.href.replace(/[^ -~]/g, ''),
},
index: link.start,
}),
Expand Down

0 comments on commit 7f4649a

Please sign in to comment.