HTML

发布于 2024-09-12 13:18:58 字数 649 浏览 5 评论 0原文

我正在处理一些包含

<div class="mycomment" dir="RTL">
  <form method="get" action="{$self}">
    <input type="hidden" name="Id" value="{$entry}" />
    <textarea name="comment" class="commentarea"/></textarea>
    <br />
    <input class="button" type="submit" value="{$postlink}" />
  </form>
</div>

在 RTL 模式下,字符串显示正确,但键盘导航不正确。具体来说,在浏览英语和阿拉伯语字符串部分时,它不遵循正确的顺序。

我有什么想法可以绕过或解决这个问题吗?

I am working with some HTML which contains a <textarea>. Currently, I am testing the input of mixed LTR and RTL-based characters, such as "abcأبجABC".

<div class="mycomment" dir="RTL">
  <form method="get" action="{$self}">
    <input type="hidden" name="Id" value="{$entry}" />
    <textarea name="comment" class="commentarea"/></textarea>
    <br />
    <input class="button" type="submit" value="{$postlink}" />
  </form>
</div>

The display of the string is correct when in RTL mode, however, the keyboard navigation is incorrect. Specifically, it does not follow the correct order when going through the English and Arabic string sections.

Any ideas how I might be able to bypass or fix this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

你げ笑在眉眼 2024-09-19 13:18:58

不幸的是,根据规格,键盘导航可能是“正确的”。当尝试运行混合方向单词时,键盘快捷键(例如 Ctrl+>)要从一个单词跳转到另一个单词,开始根据字符的方向性改变方向在光标当前位置下 - 而不是从导航的角度将整个字符串视为单向。

不过,当您考虑计算机在输入混合模式句子时需要如何解释所有其他击键时,这是可以理解的。

如果您开始输入 LTR 字符,您希望它们从左到右移动(每个后续字符出现在最后一个字符的右侧)。但是,如果您开始输入 RTL 字符,您会希望它们从右向左移动(每个后续字符都出现在最后一个字符的左侧)。

可以这样想:

Ctrl+> 并不意味着“向右移动一个单词” - 它意味着“转到下一个单词” ”。在 RTL 环境中,下一个单词位于左侧 - 因此键盘会将您跳转到该方向。

Next本质上与字节在内存中保存的顺序有关,而不是与字符显示的顺序有关屏幕。无论单词从屏幕的右侧还是左侧开始,字符都会按顺序保存在内存中,从单词的开头开始,到单词的结尾结束。

换句话说:Ctrl+> 按字节顺序移动,而不是按显示顺序移动。

所以 - 回到你如何克服它的问题......

除非你要编写一些相当复杂的 JavaScript(其中包含它自己的一系列挑战和麻烦)来改变键盘导航在你的盒子内的工作方式,否则没有什么好处方法来“修复”它。但是,如果您认为这会对您的客户产生负面影响,您可以尝试以下替代方案:

  1. 提供培训。了解古怪的键盘技巧的细节,并教授您的用户。 (我知道,我知道,有很多工作,而且你可能没有时间/预算)。
  2. 信任您的用户。如果您的用户在您的应用程序中输入混合LTRRTL文本,那么他们也可能在其他<中经常这样做/em> 应用程序。这意味着他们可能已经习惯了这组问题,因为这是一组标准问题。如果他们经常这样做 - 他们可能已经有了习惯的解决方法 - 而您更改它来修复它实际上可能伤害他们的生产力。
  3. 记录它,并提交功能请求。如果您认为特定的浏览器供应商(例如 Microsoft)应该以不同的方式实现这一点,请积极参与其用户社区并推动更新、补丁和功能添加。这就是软件世界变得更好的方式 - 并且它不会将作为变革推动者的负担仅仅放在您的组织身上,或者更糟糕的是,将责任放在您身上。

Unfortunately, the keyboard navigation is probably "correct" according to the specifications. When attempting to run through mixed-direction words, keyboard shortcuts such as Ctrl+>, to jump from word to word, start changing direction depending on the directionality of the characters under the cursor's current position - rather than treating the entire string as uni-directional from a navigation standpoint.

This is understandable, though, when you consider how the computer needs to interpret all other keystrokes while typing in mixed-mode sentences.

If you start typing LTR characters, you expect them to travel left-to-right (with each subsequent character appearing to the RIGHT of the last). If you start typing RTL characters, however, you expect them to travel right-to-left (with each subsequent character appearing to the LEFT of the last).

Think of it this way:

Ctrl+> doesn't mean "go right one word" - it means "go to the next word". In an RTL environment, the next word is to the left - so the keyboard jumps you that direction.

Next, in essence, relates to the order in which bytes are held in memory, rather than relating to the order in which characters are displayed on the screen. Whether a word starts on the right or left of the screen, the characters are held sequentially in memory, starting with the beginning of the word, and ending with the end of the word.

In other words: Ctrl+> travels in byte-order, rather than display-order.

So - back to your question of how to overcome it...

Unless you were to write some fairly complicated JavaScript (which contains its own set of challenges and troubles) to alter the way the keyboard navigation works within your boxes, there is no good way to "fix" it. However, you could try the following alternatives, if you feel it will negatively impact your customers:

  1. Provide training. Learn the in's and out's of the quirky keyboard tricks, and teach your users. (I know, I know, a lot of work and you probably don't have the time/budget).
  2. Trust your users. Chances are, if your users are inputting mixed LTR and RTL text in your application, it's also something they do regularly in other applications. This means they are probably used to this set of issues, because it's a standard set of issues. If they do it a lot - they probably already have workarounds which they're used to - and you changing it to fix it might actually hurt their productivity.
  3. Document it, and submit feature requests. If you think this is something a given browser or vendor (like Microsoft) should implement differently, get active in their user community and push for updates, patches and feature additions. This is how the world of software gets better - and it doesn't put the burden of being the change-agent solely on your organization, or, worse - on you.
鹤仙姿 2024-09-19 13:18:58

哈哈,2010 年代真的很艰难。

只需添加这个 css 属性就可以了:

    unicode-bidi: plaintext;

LOL, 2010s were really hard.

Just put this css property and you are good to go:

    unicode-bidi: plaintext;
懒猫 2024-09-19 13:18:58

事实上你做不到。
作为一个说希伯来语的人,我可以告诉你,这方面存在很多问题,特别是当你混合 RTL 和 LTR 语言或有时混合数字时。
你无能为力。有时浏览器可以处理它,有时则不能。
例如,在 Chrome 中,当您使用 Ctrl 键在希伯来语文本中加快速度时,左右键的方向会变为相反。

Actually you cannot do it.
As an Hebrew speaking person I can tell you that there are lot's of problems in this area, especially when you mix RTL and LTR languages or sometimes numbers.
There is nothing you can do. Sometimes the browser can handle it and sometimes it can't.
For example in Chrome when you use Ctrl key to go faster inside an Hebrew text, the directions of the right and left keys change to their opposite.

唠甜嗑 2024-09-19 13:18:58

您需要做的就是添加带有样式的 div:

<div style="direction:ltr">
<textarea id="geometry" class="form-control" placeholder="Lat lon" rows="3"></textarea>
</div>

All you need to do is add div with style:

<div style="direction:ltr">
<textarea id="geometry" class="form-control" placeholder="Lat lon" rows="3"></textarea>
</div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文