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: handle link open on click
Abdullah Attab4161644d0e3
diff --git a/packages/editor/src/extensions/link/helpers/clickHandler.ts b/packages/editor/src/extensions/link/helpers/clickHandler.tsindex 68795dd75..be5fc0689 100644--- a/packages/editor/src/extensions/link/helpers/clickHandler.ts+++ b/packages/editor/src/extensions/link/helpers/clickHandler.ts@@ -17,12 +17,13 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { getAttributes } from "@tiptap/core";+import { Editor, getAttributes } from "@tiptap/core";import { MarkType } from "@tiptap/pm/model";import { Plugin, PluginKey } from "@tiptap/pm/state";type ClickHandlerOptions = {type: MarkType;+ editor: Editor;};export function clickHandler(options: ClickHandlerOptions): Plugin {@@ -50,10 +51,12 @@ export function clickHandler(options: ClickHandlerOptions): Plugin {const link = event.target as HTMLLinkElement;const href = link?.href ?? attrs.href;- const target = link?.target ?? attrs.target;+ // const target = link?.target ?? attrs.target;if (link && href) {- if (view.editable) window.open(href, target);+ if (view.editable) {+ options.editor.storage.openLink?.(href);+ }return true;}diff --git a/packages/editor/src/extensions/link/link.ts b/packages/editor/src/extensions/link/link.tsindex 29263c647..4d351071f 100644--- a/packages/editor/src/extensions/link/link.ts+++ b/packages/editor/src/extensions/link/link.ts@@ -273,7 +273,8 @@ export const Link = Mark.create<LinkOptions>({if (this.options.openOnClick) {plugins.push(clickHandler({- type: this.type+ type: this.type,+ editor: this.editor}));}