-
-
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 #116
Comments
Hey @GabrielKol, |
Hey @philippkuehn I would like the direction to automatically change based on the language I'm using. It should automatically switch the direction based on the text's language. The only way I know of to implement this, is using the dir attribute on an html tag and setting it to "auto". So if I could give each p tag the dir="auto" attribute it would behave as I expect it to. |
Okay, I'm not sure about implementing this by default. What you can do is to use a custom paragraph extension. Since it's a default extension you have to overwrite it. import { setBlockType } from 'tiptap-commands'
import { Node } from 'tiptap'
export default class Paragraph extends Node {
get name() {
return 'paragraph'
}
get schema() {
return {
content: 'inline*',
group: 'block',
draggable: false,
parseDOM: [{
tag: 'p',
}],
toDOM: () => ['p', { dir: 'auto' }, 0],
}
}
commands({ type }) {
return () => setBlockType(type)
}
} There is an option to disable the default extensions ( import { Doc, Text } from 'tiptap'
import Paragraph from './CustomParagraph.js'
const editor = new Editor({
useBuiltInExtensions: false,
extensions: [
new Doc(), // default extension
new Text(), // default extension
new Paragraph(), // your custom extension
... // all other extensions
],
}) |
Thank you @philippkuehn |
I still hope it gets implemented by default or activated through an option instead of making a custom paragraph plugin. Slate has it by default and it's a really great addition with almost no cost. |
@philippkuehn At least 4% of the web is based on RTL languages. Could you please reconsider? |
@philippkuehn Your amazing project is getting adopted by the mainstream since it is part of what Nextcloud is making, it only make sense to support the languages that has the opposite direction, all it needs is implementing I tried to add |
@themedleb There're two ways to achieve that.
|
I noticed that when I was playing with the HTML in the browser inspector.
That's how it should be done of course, yesterday I mentioned it in here nextcloud/text#882 (comment), but I guess the developer is not caring much about it. |
If anyone else needs this, I have done it through simple CSS, just direction="rtl" and text-align: "right".
It seems to work just as it should. It is not Automatic, but if you have information about language, ( navigator.language for example ) it will work. |
I had the same problem and eventually I decided to extend TextAlign extension like the following
Hope that helps :) |
Hey everyone. I wrote a small extension that automatically adds |
Thank you @amirhhashemi will check it out. |
Is there a way to inject the dir="auto" attribute to all p tags?
It would be nice if each paragraph's direction would automatically change based on the language in it.
The text was updated successfully, but these errors were encountered: