A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
editor: add support for converting md link syntax to link on paste (#3919)
Muhammad Aliff36f0259a66
diff --git a/packages/editor/src/extensions/link/link.ts b/packages/editor/src/extensions/link/link.tsindex 49db86316..74ea2c5a8 100644--- a/packages/editor/src/extensions/link/link.ts+++ b/packages/editor/src/extensions/link/link.ts@@ -16,11 +16,11 @@ GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { markInputRule } from "@tiptap/core";+import { markInputRule, markPasteRule } from "@tiptap/core";import TiptapLink from "@tiptap/extension-link";const linkRegex = /(?:__|[*#])|\[(.*?)\]\(.*?\)/gm;-const regExp = /\((.*?)\)/;+const regExp = /\((.*?)\)/gm;export const Link = TiptapLink.extend({addInputRules() {@@ -28,9 +28,24 @@ export const Link = TiptapLink.extend({markInputRule({find: linkRegex,type: this.type,- getAttributes: (match) => ({- href: regExp.exec(match[0])?.[1]- })+ getAttributes: (match) => {+ return {+ href: regExp.exec(match[0])?.[1]+ };+ }+ })+ ];+ },+ addPasteRules() {+ return [+ markPasteRule({+ find: linkRegex,+ type: this.type,+ getAttributes(match) {+ return {+ href: regExp.exec(match[0])?.[1]+ };+ }})];}