sjdemartini / mui-tiptap

A Material UI (MUI) styled WYSIWYG rich text editor, using Tiptap
MIT License
299 stars 40 forks source link

Fix bug not being able to disable H1 #247

Closed mortmoe closed 2 months ago

mortmoe commented 2 months ago

Suggested fix for #228

mortmoe commented 2 months ago

I'll do my best and try to fix this tomorrow. I'm a bit of a noob when it comes to working with GitHub, kind of my first time doing something like this 🤣 Googling like a maniac on how to get this tested locally, use Forks and all that 🤣 Fun to learn new stuff and probably long overdue anyway so I'll figure it out 👍

mortmoe commented 2 months ago

I think I've got it now. As I said, kind of new to this... I've tried several methods for using and testing this in my application:

  1. By linking to my local computer: "yarn add link:/home/morten/PhpstormProjects/mui-tiptap". In this case I run npm run build in this project, and it seems to work but I get a runtime error, something is wrong with useState. Tried just adding a symlink in node_modules as well but same result.
  2. Installing from my fork: "yarn add mui-tiptap@https://github.com/mortmoe/mui-tiptap.git". It gets installed but no dist folder in the node_modules/mui-tiptap ... so it fails to get the "dist/esm/index". When installing from your original I see the dist folder.
  3. Adding "npm run build" to the prepare script in package.json and pushing to the fork fixes 2: npm run build && husky install However, this fails on my projects gitlab ... wrong node version, so I need to wait util the right guy returns from vacation before I can fix that and publish a working version for my test-users.

I'm probably missing something obvious in 1. and 2. right? :)

Anyway, I've tested the changes using method 3 and removed the build stuff now :)

sjdemartini commented 2 months ago

Thanks for cleaning up the commits and working through this! I'll make a couple tiny tweaks to the comments and variable definitions and merge this soon! 😄

In terms of testing out your change, I would recommend just testing with pnpm dev (see https://github.com/sjdemartini/mui-tiptap/blob/main/CONTRIBUTING.md#development-setup) and changing useExtensions to use HeadingWithAnchor.configure({ levels: [2,3,4] }) or whatever headings you like here https://github.com/sjdemartini/mui-tiptap/blob/61d3f7a3dccea6b7c676fdae0b15176746beb390/src/demo/useExtensions.ts#L154.

If you want to test within your own project (which shouldn't be necessary for this specific bug fix, but maybe useful otherwise), I've found https://github.com/wclr/yalc to be a convenient option.

mortmoe commented 2 months ago

Cool. Thanks for this, and thanks for the tips :) I did some testing with dev actually, just wanted to get it working locally to find a way to do it for other cases later on. I'll look into yalc next time :)