A quick search shows that CodeMirror has nice RTL support: https://codemirror.net/demo/bidi.html
If Obsidian can add a similar command, that can be mapped to a keyboard shortcut, to switch between LTR/RTL for a specific note, it’ll be amazing.
Any update from the obsidian team on this? is this something you consider working on?
Until we either get formal RTL support or the formal plugin API, here’s a hacky Volcano plugin for RTL/LTR switching.
It adds a global command “Switch Document Direction” which can be mapped to a key.
It’s probably not perfect and there’s plenty of room for improvement, but maybe it will be useful for some.
(to be saved as rtl.js
under ~/volcano/plugins
after installing Volcano)
class RTLPlugin {
constructor() {
this.id = 'rtl'
this.name = 'RTL plugin'
this.description = 'RTL support for Obsidian.'
this.defaultOn = true // Whether or not to enable the plugin on load
}
init(app, instance) {
console.log('RTL plugin is initializing!')
this.app = app
this.instance = instance
this.enabled = false
this.instance.registerGlobalCommand({
id: 'switch_direction',
name: 'Switch Document Direction',
callback: () => this.switchDocumentDirection()
})
}
onEnable(app, instance) {
console.log('RTL support is now enabled')
this.enabled = true
}
onDisable(app, instance) {
console.log('RTL support is now disabled')
this.enabled = false
}
switchDocumentDirection() {
if (this.enabled) {
var cmEditor = this.app.workspace.activeLeaf.view.currentMode.cmEditor
if (cmEditor) {
var newDirection = cmEditor.getOption("direction") == "ltr" ? "rtl" : "ltr"
cmEditor.setOption("direction", newDirection)
}
}
}
}
module.exports = () => new RTLPlugin()
+1 I wish for this to be implemented
Thanks for the solution. But it just move text to the right and doesn’t work for Persian English text.
I thought of dropping a note here, that I posted a proper RTL support plugin to the Obsidian Third-party plugins.
This includes the real deal of setting RTL paragraph direction to all or just some notes in the Markdown editor mode (didn’t do preview yet).
Is there a way to add in this plugin a capability to RTL only one paragraph instead of the whole note?
I wish, but CodeMirror (the component behind Obsidian’s editor) can only set the direction for the whole document.
+1 for RTL support (mixed English/Other languages)
Really needed
Thanks for the plugin.
please make RTL for Preview mode as well.
Will do, as it’s a very requested feature.
You are a true gold!
I published a new version 0.0.3 with preview mode RTL support, please upgrade and let me know how it works for you.
This is just great! THANK YOU!
One question: When exporting to pdf the text is still LTR, is there something I need to do in order to fix it or is it a known issue?
Thanks again!
It should be pretty easy for the author to target print, which has class .print
.
@esm90: great work you’re doing here! Have you considered opening a share & showcase thread if you haven’t? You can gather feedback and post updates there.
Otherwise, I think people are also discovering it by searching for “RTL” in third-party plugins.
@dorongol seems like it’s an area I didn’t cover yet. It should be easy enough, I’ll address that next time I have a few minutes to work on the plugin. You’re also very welcome to open a PR in the plugin Github repo if you’re up to it
@Silver thanks for the tip, I didn’t think about it. If it’s gonna help users to discover the RTL support I’ll surely open a share & showcase thread.
I added Export support in the latest version, please give it a go and let me know if it works as expected.
Thanks.
It works like a charm.
Looking forward for Apply RTL Support in link popup window.
Thank you very much for the plugin.
That RTL export is awesome. I tried multiple apps, couldn’t figure a easy way for doing it to Markdown.