-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Refactor - Migrate to Plate #575
Refactor - Migrate to Plate #575
Conversation
…plate-common package
c150327
to
b2d7993
Compare
Addressed all the remarks and fixed the encountered bugs, so this is ready for a review again 🙂 @e1himself @yuriyyakym |
packages/slate-editor/src/extensions/flash-nodes/components/FlashNodes.tsx
Show resolved
Hide resolved
editor: createEditorFactory(() => | ||
createEditor(createSlateEditor(), () => extensions, [withReact, withHistory]), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... Isn't it weird that the tests hyperscript is not using the Plate's editor implementation? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little bit, yes. It is on my roadmap to rework the tests to use Plate (soon). It will be required when we start refactoring plugins/extensions to Plate plugins as otherwise we can't use them in tests.
@@ -25,7 +22,7 @@ import { | |||
} from './plugins'; | |||
|
|||
export function createEditor( | |||
baseEditor: Editor, | |||
baseEditor: SlateEditor, | |||
getExtensions: () => Extension[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not a question for this round of refactoring, but do you know why we pass the extensions as a getter callback? Why not pass it directly as an array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Judging from this code, it seems like it's just there so the editor
is not recreated when/if extensions array changes? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've checked the updates, everything looks reasonable.
Good job Lukas 👍
I am still struggling with keeping in mind different sources of types and helper functions. Just as an idea (not for this PR probably): what do you think if we introduce an intermediate #types
module that would re-export the editor/element/node types to use inside the codebase? This way there will be a single source of types, and hopefully, it will make things less confusing?
Can you clarify this a little bit more? Are you saying we would have our |
This is the first part of the migration to Plate, replacing the main React component and all the code that depends on it with the Plate counterpart or Plate types.
For now, most of the existing plugins (extensions) have been left as-is so the PR doesn't become massive. This should also make sure that the editor behaviour stays the same.
One of the changes I've made has been to the
plugins
prop of theEditor
component, which now accepts an array ofPlatePlugin
interface, allowing us to provide plugins from the outside, which is something we're planning to do eventually.In the meantime, when this PR is in review and we can test the editor in Prezly, I'll work on refactoring the plugins to use Plate plugin approach and/or replacing them with existing Plate plugins to get rid of as much custom code as possible.