-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Bidirectional text improvements #7557
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Is there any way to update this branch with the latest version of TiddlyWiki? |
@Jermolene |
✅ Deploy Preview for tiddlywiki-previews ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hi @kookma I've updated this branch. Let me know if you run into anything. |
@Jermolene -- I did just have a look at the code here and I could not find any difference to the original "reverted" PR. So does this one still have the performance penalty? |
As I said in that original comment "Sadly, this PR will have to be reverted. I'll also create a new PR with the changes so that we can continue investigations". So at this point this is a duplicate of the original PR so that we can continue to experiment; we can't use #4541 because that has already been merged. |
Thank you, Jeremy! This works like TW-5.3.0pre. |
And fix 182 test files!
This PR is a recreation of #4541 which was merged and then later reverted when it was discovered that it caused a serious performance regression.
TiddlyWiki's language plugin mechanism includes a primitive mechanism for setting the HTML 5 "dir" attribute on the document body to "RTL", thus switching the direction of the user interface. This mechanism is used by languages such as Farsi and Hebrew.
Some of the issues with the current approach is that it is hard to work with tiddlers that have a different directionality to the main interface. For example, the document direction is "LTR" when using the default "en-GB" language plugin, but pasting (say) Farsi into the title, tags, or text fields of a tiddler doesn't switch direction to "RTL".
Prompted by discussions with @kookma, this experimental PR explores two separate mechanisms that help when working with text of a different directionality than the main interface.
The first is a new
\dir rtl
pragma that can be used at the top of a tiddler to specify that it should be rendered as RTL. This setting is respected if the tiddler content is transcluded elsewhere.(A shortcoming at present is that the
\dir
pragma must be used after any\define
pragmas if those macro definitions are to be imported elsewhere with the `\import' pragma).The second change in this PR is support for a new $:/config/DefaultTextDirection hidden setting. It can be set to "rtl", "ltr" or "auto". It sets the "dir" attribute on several different parts of the view template and edit template.
The interesting thing is the setting "auto", part of the HTML 5 spec. It applies a simple heuristic to detect the appropriate direction for a fragment of text. The default value of $:/config/DefaultTextDirection is "auto". With this setting in place it becomes possible to paste fragments of RTL text into titles, tags, or text fields, and have things work as expected.
(A shortcoming that won't be going away is that the CodeMirror engine doesn't support "auto", just the explicit "RTL" and "LTR" settings. So I think we'll have to handle that entirely differently.
The change that I haven't explored here is adding a "_direction" field on individual tiddlers. That would work much better with the CodeMirror editor, but the disadvantage is that transclusion wouldn't respect the setting.