-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Rtl Support dynamically when user type first char #1621
Comments
See: #116 Still, if not default, it would be nice to have |
Following the guide for global attributes I came up with a quick and dirty extension. (For some reason lists and blockquotes only work in Firefox.) import { Extension } from '@tiptap/core'
const AutoDir = Extension.create({
addGlobalAttributes() {
return [
{
types: [
'heading',
'paragraph',
'blockquote',
'bulletList',
'orderedList',
],
attributes: {
autoDir: {
renderHTML: attributes => ({
dir: 'auto',
}),
parseHTML: element => ({
autoDir: element.dir.autoDir || 'auto',
}),
},
},
},
]
},
}) |
Update: to make blockquotes and lists work, Here is a test for this issue: https://codepen.io/cadars/pen/poeXMXZ?editors=1100 |
Updated to work with the import { Extension } from '@tiptap/core'
const AutoDir = Extension.create({
name: 'AutoDir',
addGlobalAttributes() {
return [
{
types: [
'heading',
'paragraph',
'bulletList',
'orderedList',
'blockquote',
],
attributes: {
autoDir: {
renderHTML: attributes => ({
dir: 'auto',
}),
parseHTML: element => element.dir || 'auto',
},
},
},
]
},
}) |
For now, adding a custom extension is the preferred way. |
Hey everyone. I wrote a small extension that automatically adds dir="rtl" or dir="ltr" based on the node's content. You might find it useful: https://github.com/amirhhashemi/tiptap-text-direction |
The problem I am facing
when I want to type persian like "سلام"
I Cant change direction
The solution I would like
dynamically change dir and added to classname list of that element
because when I saved my work and use dangerouslyhtml then without any side effects I show my persian language with dir="rtl"
Alternatives I have considered
nothing
Additional context
nothing and thanks for this cool package
The text was updated successfully, but these errors were encountered: