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