plate
plate copied to clipboard
Feat/mark affinity
@12joan We have discussion at #2530 .Are these the contents you expressed?
⚠️ No Changeset found
Latest commit: 841e8ab99a976a0d30fd51ff2ca008a477882387
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| plate | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Apr 26, 2024 7:20am |
@12joan I have accept your suggestion. I intend to spilt this feature into three plugin.This is the createNaturalMarkAffinityPlugin one.
it exclude the mark which have padding-left or padding-right like MARK_CODE.
Due to limitations with Slate, we cannot set the cursor to the far left and within the code.and this mark have padding-left it will be strange.
It should create a new plugin to handle this case.Right now I have no ideal.
The third plugin will conflict with the first plugin, resulting in a cursor that moves in steps.
it exclude the mark which have padding-left or padding-right like MARK_CODE. Due to limitations with Slate, we cannot set the cursor to the far left and within the code.and this mark have padding-left it will be strange. It should create a new plugin to handle this case.Right now I have no ideal.
Is this the bug where setting the affinity to the left while at the start of an inline code mark creates a new, empty inline code mark to the left of it? If it's possible to fix that (which I'm not 100% sure it is), that would have to be fixed in slate-react.
In my app, I've addressed this by switching to an inline code style without any padding.
it exclude the mark which have padding-left or padding-right like MARK_CODE. Due to limitations with Slate, we cannot set the cursor to the far left and within the code.and this mark have padding-left it will be strange. It should create a new plugin to handle this case.Right now I have no ideal.
Is this the bug where setting the affinity to the left while at the start of an inline code mark creates a new, empty inline code mark to the left of it? If it's possible to fix that (which I'm not 100% sure it is), that would have to be fixed in slate-react.
In my app, I've addressed this by switching to an inline code style without any padding.
yeah,it have to be fixed in slate-react I think it will be not easy.
Thank your valuable advice. @12joan
@gooroodev are you able to review this?
Appreciate the heads-up, @admsev!
Summary of Changes
-
New Package Addition:
- Added a new package
@udecode/plate-marks-affinityto manage mark affinity in the editor.
- Added a new package
-
Dependency Updates:
- Updated
apps/www/package.jsonto include the new package as a dependency.
- Updated
-
Playground Demo:
- Modified
apps/www/src/registry/default/example/playground-demo.tsxto integrate the new mark affinity plugin. - Added new constants for various marks such as
MARK_BOLD,MARK_ITALIC, etc., to the imports. - Integrated
createMarkAffinityPluginwith valid marks in theusePlaygroundPluginsfunction.
- Modified
-
New Package Files:
- Created new files in the
packages/mark-affinitydirectory:.npmignoreREADME.mdpackage.jsonsrc/createMarkAffinityPlugin.tssrc/index.tssrc/queries/getMarkBoundary.tssrc/queries/getMarkBoundaryAffinity.tssrc/queries/index.tssrc/transforms/index.tssrc/transforms/setMarkBoundaryAffinity.tssrc/types.tssrc/withMarkAffinity.tstsconfig.json
- Created new files in the
-
Utility Updates:
- Modified
packages/utils/src/environment.tsto include a new constantIS_FIREFOX.
- Modified
Issues, Bugs, or Typos
-
Typo in README:
- In
packages/mark-affinity/README.md, the word "futures" should be corrected to "features".
- In
-
Comment Issue:
- In
withMarkAffinity.ts, there's a TODO comment that seems incomplete://TODO: note the comment_x. It should be either completed or removed if not needed.
- In
-
Unnecessary Null Checks:
- In
getMarkBoundary.ts, the return type ofgetNodeEntryis already nullable, so the explicit?? nullchecks might be redundant.
- In
Code Improvements
-
Typo Correction in README:
- This package implements the following futures: + This package implements the following features: -
Complete or Remove TODO Comment:
- //TODO: note the comment_x -
Simplify Null Checks in
getMarkBoundary.ts:- const adjacentNode = getNodeEntry(editor, adjacentPath) ?? null; + const adjacentNode = getNodeEntry(editor, adjacentPath); - const adjacentLeafEntry = - adjacentNode && isText(adjacentNode[0]) - ? (adjacentNode as NodeEntry<TText>) - : null; + const adjacentLeafEntry = adjacentNode && isText(adjacentNode[0]) + ? (adjacentNode as NodeEntry<TText>) + : null;
General Review of Code Quality and Style
-
Code Consistency:
- The code is consistent in terms of style and follows typical TypeScript and React best practices.
- Proper use of TypeScript interfaces and types enhances code readability and maintainability.
-
Documentation:
- The newly added
README.mdprovides a brief overview and a link to further documentation, which is good for new users of the package.
- The newly added
-
Modular Design:
- The new functionality is well encapsulated within its package, adhering to the modular design principles.
-
Code Comments:
- The code is well-commented, explaining the purpose of various functions and the logic behind certain decisions.
-
Error Handling:
- The code generally checks for null or undefined values, ensuring robustness.
Overall, the changes are well-structured and integrate seamlessly with the existing codebase. The new functionality for managing mark affinity is clearly defined and implemented in a modular fashion.
Yours, Gooroo.dev. Please add a reaction or reply with your thoughts!

