GuavaCZ / filament-knowledge-base

MIT License
116 stars 17 forks source link

[Bug]: Not compatible with tiptap editor #11

Closed DevRaeph closed 3 months ago

DevRaeph commented 3 months ago

What happened?

If you try to use it along with tiptap editor you can't install it.

` Problem 1

You can also try re-running composer require with an explicit version constraint, e.g. "composer require guava/filament-knowledge-base:*" to figure out if any version is installable, or "composer require guava/filament-knowledge-base:^2.1" if you know which you need. `

How to reproduce the bug

Is it possible to change the spatie/shiki-php package to version 1.3 instead of ^2.0? I guess this would solve the bug.

Package Version

newest

PHP Version

8.3

Laravel Version

11.6

Which operating systems does with happen with?

macOS

Notes

No response

gavinhewitt commented 3 months ago

@lukas-frey This was the plugin that needed to be removed in order to be able to install KB. I think I also needed to remove Curator (both by AWCodes).

DevRaeph commented 3 months ago

Sadly, the "ueberdosis/tiptap-php" repo seems abandoned. This is used by AWCodes for the TipTap Editor.

lukas-frey commented 3 months ago

I'm honestly not sure what difference there is between version 1.3 and 2.0, I'll need to check and see if I can support both of the versions.

Alternatively I can add shiki-php as an optional dependency, since you need to opt-in for the functionality anyways (because of the additional installation steps).

DevRaeph commented 3 months ago

it seems there isn't a bis difference between these two packages.

The getAvailableLanguages, getAvailableThemes, languageIsAvailable and themeIsAvailable methods have been removed. These are no longer necessary as Shiki 1.0 lazy loads these when necessary.

But an option Opt-in would be amazing for now :)

lukas-frey commented 3 months ago

So I tested it now with 1.3 and it doesn't work. It seems like shiki.js uses an async import call and prior to version 2.0, it imported using a require call, which seems to cause issues now.

If anyone knows a way around this, feel free to PR backwards compatibility for 1.3, but for now I'll have to keep it to 2.0.

I should be able to add it as an optional dependency only though, so it should work even when using tip-tap editor, but without the syntax highlighting feature.

DevRaeph commented 3 months ago

i'll check if i can accomplish a backwards compatibility :)

lukas-frey commented 3 months ago

i'll check if i can accomplish a backwards compatibility :)

That would be neat! :)

For now, version 1.2.0 has spatie/shiki-php only as a suggested package and if you want to use syntax highlighting, you need to manually install it.

EDIT: Feel free to try it out and reopen if you encounter any issues with it.

DevRaeph commented 3 months ago

I've tried it now, and i got i working without any problems.

image

I've just changed your composer.json to "spatie/shiki-php": "^1.3", and the package.json to "shiki": "^0.10.0",. if you run npm i shiki@0.10.0 it worked without any problems.

The only thing i encouted, thats my problem i guess, i needed to add '/Users/myuser/Library/Application Support/Herd/config/nvm/versions/node/v21.7.3/bin' to the getLanguage function in FencedCodeRenderer.php on line 35.

i guess thats a problem with herd :D

lukas-frey commented 3 months ago

I've tried it now, and i got i working without any problems.

image

I've just changed your composer.json to "spatie/shiki-php": "^1.3", and the package.json to "shiki": "^0.10.0",. if you run npm i shiki@0.10.0 it worked without any problems.

Okay, I did not change the JS version of the package, but we need to make sure it works with both 1.3 and 2.0.

The only thing i encouted, thats my problem i guess, i needed to add '/Users/myuser/Library/Application Support/Herd/config/nvm/versions/node/v21.7.3/bin' to the getLanguage function in FencedCodeRenderer.php on line 35.

i guess thats a problem with herd :D

That's not a problem with Herd (I mean it kinda is), but the solution is different, I linked it in the documentation: https://github.com/spatie/shiki-php?tab=readme-ov-file#using-node-version-manager

You should symlink your nvm node to the place where it would normally be if you installed it locally.

DevRaeph commented 3 months ago

yeah i think both will work. Just apply the little hint in the docs with the other Versions and i think this will be good to go :)

lukas-frey commented 3 months ago

yeah i think both will work. Just apply the little hint in the docs with the other Versions and i think this will be good to go :)

You are right, spatie/shiki-php 1.x works with shiki 0.x and spatie/shiki-php 2.x works with shiki 1.x.

I still like keeping it opt-in due to the installation steps that are present anyways, I'll add the info about the different versions then.

Thanks a lot for looking into it Raphael!

DevRaeph commented 3 months ago

No Problem, please adapt also the "syntaxHighlighting" funciton where you check for the installed version. Thanks for the effort and keep it up :)

lukas-frey commented 3 months ago

Done in 1.2.1