Darginec05 / Yoopta-Editor

Build Notion-like, Craft-like, Coda-like, Medium-like editors with Yoopta
https://yoopta.dev/
MIT License
1.08k stars 83 forks source link

[BUG] Link's plugin doesn't mount #222

Closed MistPandora closed 1 month ago

MistPandora commented 1 month ago

Has this bug been raised before?

Description

I'm in a React/Next14 project, trying to implement Yoopta and I figured out there's the Link Plugin missing.

Steps to Reproduce

'use client'

import Accordion from '@yoopta/accordion';
import ActionMenuList, { DefaultActionMenuRender } from '@yoopta/action-menu-list';
import Blockquote from '@yoopta/blockquote';
import Callout from '@yoopta/callout';
import Code from '@yoopta/code';
import YooptaEditor, { createYooptaEditor } from '@yoopta/editor';
import Embed from '@yoopta/embed';
import File from '@yoopta/file';
import { HeadingOne, HeadingThree, HeadingTwo } from '@yoopta/headings';
import Image from '@yoopta/image';
import Link from '@yoopta/link';
import LinkTool, { DefaultLinkToolRender } from '@yoopta/link-tool';
import { BulletedList, NumberedList, TodoList } from '@yoopta/lists';
import { Bold, CodeMark, Highlight, Italic, Strike, Underline } from '@yoopta/marks';
import Paragraph from '@yoopta/paragraph';
import Toolbar, { DefaultToolbarRender } from '@yoopta/toolbar';
import Video from '@yoopta/video';
import { useMemo, useRef } from 'react';

const plugins = [
    Paragraph,
    Accordion,
    HeadingOne,
    HeadingTwo,
    HeadingThree,
    Blockquote,
    Callout,
    NumberedList,
    BulletedList,
    TodoList,
    Code,
    Link,
    Embed,
    Image,
    Video,
    File
];

const TOOLS = {
    ActionMenu: {
        render: DefaultActionMenuRender,
        tool: ActionMenuList,
    },
    Toolbar: {
        render: DefaultToolbarRender,
        tool: Toolbar,
    },
    LinkTool: {
        render: DefaultLinkToolRender,
        tool: LinkTool,
    },
};

const MARKS = [Bold, Italic, CodeMark, Underline, Strike, Highlight];

export default function CustomEditor() {
    const editor = useMemo(() => createYooptaEditor(), []);
    const selectionRef = useRef(null);

    return (
        <div
            className="flex justify-center px-[20px] pb-[40px] pt-[80px] md:py-[100px] md:pl-[200px] md:pr-[80px]"
            ref={selectionRef}
        >
            <YooptaEditor
                editor={editor}
                plugins={plugins}
                tools={TOOLS}
                marks={MARKS}
                selectionBoxRoot={selectionRef}
                autoFocus
            />
        </div>

    )
}

Environment

Screenshots

Capture d’écran 2024-07-24 000650

Do you want to work on this issue?

No

If "yes" to above, please explain how you would technically implement this

No response

Darginec05 commented 1 month ago

Hi @MistPandora Link is plugin with root element which is inline, it means that link element should be rendered inside block elements as inline. So, Action Menu shows only plugin with nodeType: 'block', not 'inline'

Darginec05 commented 1 month ago

@MistPandora Please reopen issue If you will have any questions about this approach