initial commit. gotta go
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react";
|
||||
import React, { useCallback, useState } from "react";
|
||||
import { BubbleMenu as BaseBubbleMenu } from '@tiptap/react';
|
||||
import React, { useCallback, useState } from 'react';
|
||||
|
||||
import { MenuProps } from "../types";
|
||||
import { LinkPreviewPanel } from "../components/panels/LinkPreviewPanel";
|
||||
import { LinkEditorPanel } from "../components/panels/LinkEditorPanel";
|
||||
import { MenuProps } from '../types';
|
||||
import { LinkPreviewPanel } from '../components/panels/LinkPreviewPanel';
|
||||
import { LinkEditorPanel } from '../components/panels/LinkEditorPanel';
|
||||
|
||||
export const LinkMenu = ({ editor, appendTo }: MenuProps): React.ReactNode => {
|
||||
const [showEdit, setShowEdit] = useState(false);
|
||||
|
||||
const shouldShow = useCallback(() => {
|
||||
const isActive = editor.isActive("link");
|
||||
const isActive = editor.isActive('link');
|
||||
return isActive;
|
||||
}, [editor]);
|
||||
|
||||
const { href: link } = editor.getAttributes("link");
|
||||
const { href: link } = editor.getAttributes('link');
|
||||
|
||||
const handleEdit = useCallback(() => {
|
||||
setShowEdit(true);
|
||||
@@ -24,16 +24,16 @@ export const LinkMenu = ({ editor, appendTo }: MenuProps): React.ReactNode => {
|
||||
editor
|
||||
.chain()
|
||||
.focus()
|
||||
.extendMarkRange("link")
|
||||
.setLink({ href: url, target: "_blank" })
|
||||
.extendMarkRange('link')
|
||||
.setLink({ href: url, target: '_blank' })
|
||||
.run();
|
||||
setShowEdit(false);
|
||||
},
|
||||
[editor]
|
||||
[editor],
|
||||
);
|
||||
|
||||
const onUnsetLink = useCallback(() => {
|
||||
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
||||
editor.chain().focus().extendMarkRange('link').unsetLink().run();
|
||||
setShowEdit(false);
|
||||
return null;
|
||||
}, [editor]);
|
||||
@@ -54,7 +54,7 @@ export const LinkMenu = ({ editor, appendTo }: MenuProps): React.ReactNode => {
|
||||
updateDelay={0}
|
||||
tippyOptions={{
|
||||
popperOptions: {
|
||||
modifiers: [{ name: "flip", enabled: false }],
|
||||
modifiers: [{ name: 'flip', enabled: false }],
|
||||
},
|
||||
appendTo: () => {
|
||||
return appendTo?.current;
|
||||
@@ -63,7 +63,7 @@ export const LinkMenu = ({ editor, appendTo }: MenuProps): React.ReactNode => {
|
||||
setShowEdit(false);
|
||||
},
|
||||
}}
|
||||
className="flex gap-1 rounded-md border border-gray-200 bg-white p-1 shadow-md items-center mt-4"
|
||||
className="mt-4 flex items-center gap-1 rounded-md border border-gray-200 bg-white p-1 shadow-md"
|
||||
>
|
||||
{showEdit ? (
|
||||
<LinkEditorPanel initialUrl={link} onSetLink={onSetLink} />
|
||||
|
Reference in New Issue
Block a user