i forked lexical repo for tracking purpose fork, ideally we need to catch up commit by commit by it is fine that we just add whatever is needed.
pnpm install lexical-svelte-runes@latest @unocss/reset
im not able to make it work on stackblitz due to some weird 'cross-origin frame' but it should work in your own project, copy the code !
https://stackblitz.com/edit/vitejs-vite-pzwyu3?file=src%2FApp.svelte
When adding new plugins to lexical-svelte-runes
, use external libraries instead of copying all the logic from the React playground. This keeps our code clean and maintainable.
- Melt-UI, UnoCSS, and Svelte-ShadCN:
- Image Resize Library: For efficient image manipulation.
- ColorPicker Components: color selection.
- codebase needs cleanup remove unused files,dependencies
- imports more components from lexical playground
- setup git actions & releases...
Short version
since we use runes to polyfill react hook & svelte runes, it is super easy to port an component, simply copy the tsx into the right folder(i.e playground), then run autoFix.js to clean the import (removing $ by renaming imports) then fix the code to make it svelte-ish ! remember the output of useState const [fn,setFn]=useState()
are both function just like solid
(we also need to refractor the current repo, i.e move all plugins in to the same folder currently there are some naughty plugins outside )
- clone the lexical-svelte(the repo you are on now) repo - we will refer to the cloned repo 'svelte repo'
- clone official lexical repo - we will refer to the cloned repo 'react repo'
- go to https://playground.lexical.dev/ and pick something we dont have i.e font dropdown
- go to react repo, navigate to react playground package,
- go to toolbar and recursively copy the necessary code for font dropdown to svelte repo's toolbar
- go to editor.tsx , find the plugin for font dropdown (if there is one), recursively copy it over to svelte repo (you might also need to check https://github.com/facebook/lexical/tree/main/packages/lexical-react, we put put leixcal-playground and lexical-react in one package) , put it under
src/playground/plugins/_
, unlike react repo, we want to group by features, so all required files for a feature should be under src/plugins/_, dont need to create a separate nodes folder for nodes - now you have a bunch of
.tsx
and.ts
files under plugins/* , slowly convert each one to svelte files , for.ts
you probably just need to fix the errors due to our svelte hooks ! - you can use autoFix to rename imports since svelte does not support
$
in svelte files - remember when you convert code to svelte , you can use external libs but please keep code structure as similar to the react repo as much as possible for easier debug later on!
- remember to add node to playgroundNodes after your ported from react's repo https://github.com/facebook/lexical/tree/main/packages/lexical-playground/src/nodes
- add converted plugins to the editor.tsx in svelte repo
- remove unused files
- i.e .tsx that you used autoFix.js on or some utilities that svelte don't need
- fully migration image inserts, captions (try use a image resize lib instead of writing custom resize logic...)
- excalidraw
- finish up autocomplete(current version is customized, i couldnt get lexical-playground's version to work)
- table
- sticky note
- tweet
- youtube videos
- figma
- charts, diagrams...
- columns layout
- lexical-devtool-core