manogi / nova-tiptap

Laravel Nova Tiptap Field
MIT License
172 stars 57 forks source link

Issue rendering paragraph toolbar button (missing icon) #52

Closed mikkellindblom closed 2 years ago

mikkellindblom commented 2 years ago

Seems like the icon for the paragraph button is missing in NormalButton.vue.

Screenshot 2022-02-04 at 13 14 15
manogi commented 2 years ago

Hi there, could you please paste your Resource Class, or just the Tiptap fields inside that class? I'm not sure which button you mean. There is no "paragraph" button. Just pressing enter inside Tiptap adds a new paragraph, no button is needed. All other block elements can be turned back into a paragraph by by toggling the button again (like H1, H2, Unordered List etc.).

mikkellindblom commented 2 years ago

Hi @manogi ,

I often use the "paragraph" button to reset text pasted from elsewhere, maybe that is just me?

Tiptap::make('Content', 'content')
                ->buttons([
                    'heading',
                    'paragraph',
                    '|',
                    'italic',
                    'bold',
                    '|',
                    'link',
                    'strike',
                    'underline',
                    'highlight',
                    '|',
                    'bulletList',
                    'orderedList',
                    '|',
                    'table',
                ])
                ->headingLevels([1, 2, 3, 4])
                ->onlyOnForms(),

Maybe the following would work:

File: NormalButton.vue:

Line 58:

else if (this.button == 'paragraph') {
    return ['fas', 'paragraph'];
}

Line 109:

else if (this.button == 'paragraph') {
    command.setParagraph();
}

Ref: https://tiptap.dev/api/nodes/paragraph

manogi commented 2 years ago

Hmm. I'm not sure I would like the Paragraph button to be a "first class citizen", because people might think they actually need to use it. But I might consider adding the button, but not adding it to the Readme. I will think about it.

mikkellindblom commented 2 years ago

Sure thing, let me know what you decide :) Thanks!

manogi commented 2 years ago

I decided to add the button (is added in version v2.7.2), but I don't mention it in the Readme. Using feels a little strange to me, as there is no way to "untoggle" a paragraph, as the paragraph is the default block node. I hope it fits your use case!

mikkellindblom commented 2 years ago

Thank you @manogi!