@@ -4,7 +4,6 @@
|
||||
|
||||
import { Link } from "@tiptap/extension-link";
|
||||
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
||||
import { getAttributes } from "@tiptap/react";
|
||||
|
||||
export const LinkExtension = Link.extend({
|
||||
addProseMirrorPlugins: () => {
|
||||
@@ -24,18 +23,16 @@ export const LinkExtension = Link.extend({
|
||||
}
|
||||
},
|
||||
},
|
||||
handleClick: (view, _, event) => {
|
||||
handleClick: (_view, _, event) => {
|
||||
const { ctrlKey, metaKey } = event; // Check for Ctrl (Windows) or Cmd (Mac)
|
||||
const keyPressed = ctrlKey || metaKey;
|
||||
|
||||
if (keyPressed) {
|
||||
// Get attributes of the mark at the clicked position
|
||||
const attrs = getAttributes(view.state, "link");
|
||||
const link = (event.target as Element | null)?.closest("a");
|
||||
|
||||
if (link && attrs.href) {
|
||||
window.open(attrs.href as string, "_blank", "noopener,noreferrer"); // Open link in a new tab
|
||||
return true; // Handle the event
|
||||
if (link?.href) {
|
||||
window.open(link.href, "_blank", "noopener,noreferrer");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false; // Let other handlers run
|
||||
|
||||
@@ -185,7 +185,7 @@ export function OptionsMenu({ editor }: OptionsMenuProps) {
|
||||
wrapper.style.top = "-10000px";
|
||||
document.body.append(wrapper);
|
||||
e.dataTransfer.setDragImage(wrapper, 0, 0);
|
||||
document.addEventListener("drop", () => wrapper.remove(), { once: true });
|
||||
document.addEventListener("dragend", () => wrapper.remove(), { once: true });
|
||||
}
|
||||
|
||||
startDrag(view, slice, selection);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@import "./rich-editor.css";
|
||||
|
||||
@plugin "@tailwindcss/typography";
|
||||
@config "../tailwind.config.js";
|
||||
|
||||
@@ -278,4 +280,3 @@ button[data-cell]:focus-visible {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
@import "./rich-editor.css";
|
||||
|
||||
@@ -18,6 +18,8 @@ import { defineConfig } from "vite";
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react(),
|
||||
tailwindcss()],
|
||||
plugins: [
|
||||
react(),
|
||||
tailwindcss(),
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user