Skip to content
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

feat: text direction plugin #2888

Closed
wants to merge 1 commit into from
Closed

feat: text direction plugin #2888

wants to merge 1 commit into from

Conversation

amirhhashemi
Copy link
Contributor

@amirhhashemi amirhhashemi commented Jun 16, 2022

This is PR is moved to #2963

This is a work in progress

This plugin automatically adds dir="ltr" or dir="rtl" to specified nodes based on their content. I stole the direction detection logic from lexical

I'm still new to ProseMirror and this plugin definitely needs to be polished. I appreciate your suggestions and help.

Demo

2022-06-16.11-30-04.mp4

HTML (from devtools):

image

TODO

  • add setTextDirection and unsetTextDirection commands to manually specify the node's direction. These should have more precedence over the automatically detected direction so we can force a node to have a specific direction.
  • add a global attribute for direction so dir would be an actual attribute and will be in the HTML output. I still haven't figured out how to update a tiptap node's attributes within a ProseMirror plugin.
  • improve performance - only update direction if needed
  • add docs and update README

Why not dir="auto"?

more control

Why not a custom paragraph node?

headings and other text nodes also need it

Related issues

#116
#1621

@netlify
Copy link

netlify bot commented Jun 16, 2022

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit e40e215
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/62aad69272b82300099203e1
😎 Deploy Preview https://deploy-preview-2888--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@amirhhashemi amirhhashemi marked this pull request as draft June 16, 2022 07:08
@gethari
Copy link
Contributor

gethari commented Feb 2, 2023

@ahhshm I'm finding this useful, by any change can you tell me what happened to this ? Why it was closed ?

@amirhhashemi
Copy link
Contributor Author

amirhhashemi commented Feb 2, 2023

@gethari I accidentally removed my fork and this PR got automatically closed. I created a new one: #2963. Sorry for the confusion.

In the end, this extension didn't merge because I guess the core team didn't like it OR they didn't have the time to maintain another extension. They suggested making it my own package but I haven't had the time to do it yet. Also, some edge cases haven't been resolved.

Feel free to copy the code and use it in your project. it works fine. I have a plan to polish the code and publish
it but I'm not sure when I can do it.

@gethari
Copy link
Contributor

gethari commented Feb 2, 2023

@ahhshm Thank you for your response. Just @mention me or let me know if you get a chance to publish it :) Thanks for your time

@amirhhashemi
Copy link
Contributor Author

Hi @gethari . I finally published it!

https://github.com/amirhhashemi/tiptap-text-direction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants