-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Sveltekit? #60
Comments
I'm not familiar with Svelte, is there any error reported? I might take some time to look into the performance in Sveltekit. |
when i try and import this
it gave me this
I understand it is most likely sveltekit problem, but I was wondering if this it is possible to make it work Also, Thank you so much for responding so quickly |
@BlenderBoi I think you can create your own config that uses in Sveltekit w/ browser environment check, for example import { menu, menuConfigCtx, type MenuConfigItem } from '@milkdown-lab/plugin-menu'
import { browser } from '$app/environment';
const createIconContent = (icon: string) => {
if(!browser) return null
const span = document.createElement('span')
span.className = 'material-icons material-icons-outlined'
span.textContent = icon
return span
}
export const defaultConfigItems: MenuConfigItem[][] = [
[
{
type: 'button',
content: createIconContent('turn_left'),
key: 'Undo',
disabled: (ctx) => {
try {
if (!ctx.get('historyProviderConfig')) {
return true
}
} catch (error) {
return false
}
return false
},
},
{
type: 'button',
content: createIconContent('turn_right'),
key: 'Redo',
disabled: (ctx) => {
try {
if (!ctx.get('historyProviderConfig')) {
return true
}
} catch (error) {
return false
}
return false
},
},
],
] Might add more menu items check doc |
default config as in default config for milkdown lab? |
just in |
Sorry, Im a little new to web dev so im basicly going in blind with alot of things and my fundalmentals aren't very good Do I modify the source code to fix this? or do I write code and extend it or something? or it's not a solution, but just explaining something? I think i get the error just from importing { menu } |
Thanks. but I think there is no necessary. This problem is framework specific, It's no need to modify the source. Feel free to raise an issue for some other problem |
Ahh ok, So I guess I can't use this with Sveltekit for now? If it is then I'll just close this issue? Tho, If it is possible, then it would be nice |
I take time to create an example, you can preview it in stackblitz and its' source code in repo, which uses sveltekit w/ vite I just add simple menu items, hope it can help you |
Oh Thank you so much |
Interesting, I guess the problem lies in my sveltekit setup, I think your demo code is just svelte, so it works (maybe) I'm comparing my setup with your demo and they are very similar, but they do have differences I guess I'll have to study your demo code to figure out how to make it work on mine Maybe I just need to study how vite and svelte work more in depth My problem is not solved yet, but perhaps I got a clue now Thank you so much, I hope I can figure it out by myself |
“document is not defined” happens in nextjs too, I'm trying to create my own config as @enpitsuLin mentioned.. |
I hope this is not the wrong place to ask this
This is Regarding @milkdown-lab/plugin-menu
I am trying to add this plugin into milkdown in my Sveltekit environment, and I think it doesn't work very well with sveltekit
Is it possible for this to be compatible with sveltekit?
Thank you
The text was updated successfully, but these errors were encountered: