-
Notifications
You must be signed in to change notification settings - Fork 877
set x-slate-fragment in plateStatic #4431
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
base: main
Are you sure you want to change the base?
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
🦋 Changeset detectedLatest commit: 13dbdcd The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Claude finished @felixfeng33's task —— View job Code Review for "set x-slate-fragment in plateStatic"Review Checklist
SummaryThis PR adds copy functionality to Code Review✅ Strengths
🔍 Issues Found1. Critical: Missing
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
/changeset |
Claude finished @zbeyens's task —— View job Todo List:
SummaryCreated a changeset file for the new copy functionality in PlateStatic:
The changeset documents the addition of copy functionality to the PlateStatic component, which enables proper serialization of selected content with the |
Co-authored-by: Ziad Beyens <[email protected]>
/test |
Claude finished @zbeyens's task —— View job Todo List:
SummarySuccessfully created comprehensive test coverage for the new copy functionality in PlateStatic. The tests include:
Key FindingThe tests confirm the issue identified in the previous review: |
- Add tests for setFragmentDataStatic - Add tests for getSelectedDomBlocks - Add tests for getPlainText - Add integration tests for PlateStatic copy functionality - Tests demonstrate that data-slate-id attributes are missing Co-authored-by: Ziad Beyens <[email protected]>
/changeset |
/test |
Claude finished @felixfeng33's task —— View job Todo List:
SummarySuccessfully created comprehensive test coverage for the new PlateStatic copy functionality. The tests include:
Known IssuesSome existing tests in the project are failing due to missing dependencies (@platejs/callout, @platejs/resizable), but the new tests for the copy functionality are working correctly. The test suite covers all the new code paths and edge cases. |
variant, | ||
...props | ||
}: PlateViewProps & VariantProps<typeof editorVariants>) { | ||
return <PlateView {...props} />; |
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.
Missing variants?
}).overrideEditor(({ editor }) => ({ | ||
transforms: { | ||
setFragmentData(fragment) { | ||
return setFragmentDataStatic(editor, fragment); |
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.
No need to export this, you can move the logic here
} | ||
}; | ||
|
||
export const CopyPlugin = createTSlatePlugin({ |
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.
You can override dom plugin like ReactPlugin:
export const ViewPlugin = DOMPlugin.overrideEditor...
|
||
export type GetStaticPluginsOptions = { | ||
/** Enable copy plugin. */ | ||
copyPlugin?: boolean; |
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.
Options not needed, we'll always enable that plugin
* @param deps - Additional dependencies for the useMemo hook (default: []) | ||
* @see {@link createStaticEditor} for detailed information on static editor creation and configuration. | ||
*/ | ||
export function usePlateViewEditor< |
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.
@claude do you prefer usePlateViewEditor or useViewEditor? to match createStaticEditor, createViewEditor, usePlateEditor, createSlateEditor, createPlateEditor
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.
Claude finished @zbeyens's task —— View job
Todo List:
- Analyze the naming patterns in the codebase
- Provide recommendation for hook naming
Naming Recommendation
I prefer usePlateViewEditor
for the following reasons:
-
Consistency with existing patterns: The codebase already has
usePlateEditor
as the primary hook for creating React editors. UsingusePlateViewEditor
maintains this naming convention. -
Clear namespace distinction: The "Plate" prefix distinguishes these React-enhanced hooks from base Slate functionality. This is important because:
usePlateEditor
creates a Plate editor (React-enhanced)usePlateViewEditor
creates a Plate view editor (React-enhanced, static)- Without the prefix,
useViewEditor
could be confused with a base Slate hook
-
Parallel structure: The existing create functions follow this pattern:
createPlateEditor
→usePlateEditor
createStaticEditor
→usePlateViewEditor
Note: There's no
createViewEditor
in the codebase - the static editor is created withcreateStaticEditor
. -
Semantic clarity: The name clearly indicates this is a Plate-specific hook for view/static editors, not a generic editor hook.
The pattern useEditor*
(without "Plate") is reserved for hooks that interact with existing editors (like useEditorSelector
, useEditorPlugin
), not for creating new editor instances.
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.
@dosu do you prefer usePlateViewEditor or useViewEditor? to match createStaticEditor, createViewEditor, usePlateEditor, createSlateEditor, createPlateEditor
- Add tests for createStaticEditor with copy plugin configuration - Add tests for CopyPlugin fragment data serialization - Add tests for DOM selection utilities (getSelectedDomBlocks, getSelectedDomNode) - Add tests for isSelectOutside editor detection - Add tests for getPlainText DOM text extraction - Add tests for PlateView component copy event handling - Add tests for usePlateViewEditor hook memoization Co-authored-by: Felix Feng <[email protected]>
Checklist
yarn typecheck
yarn lint:fix
yarn test
yarn brl
yarn changeset