第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

修復(fù)從右到左語言切換時 Atom 光標(biāo)的行為

修復(fù)從右到左語言切換時 Atom 光標(biāo)的行為

夢里花落0921 2022-10-13 16:25:21
我一直在嘗試更改文本編輯器 Atom 的默認(rèn)設(shè)置,以支持 RTL(從右到左)語言。所以在課堂上,我在這里L(fēng)inesTileComponent添加了一個新屬性。dir="rtl"這已將整個腳本切換為向右切換,如此處所示。https://i.stack.imgur.com/QfBR0.gif鍵入阿拉伯語時光標(biāo)消失。對文本的任何點(diǎn)擊都不會帶回光標(biāo)(稍后在 GIF 中發(fā)生)。我無法從行外選擇一個特定的單詞,當(dāng)我在 RTL 文本之后單擊時,光標(biāo)只會出現(xiàn)在左側(cè)。我懷疑這可能是由于cursor.js、cursor.less或selection.js或其他中的代碼造成的。我正在努力解決這個光標(biāo)的行為。是否有任何特定文件或快速修復(fù)程序可以幫助您解決此問題?
查看完整描述

1 回答

?
慕少森

TA貢獻(xiàn)2019條經(jīng)驗(yàn) 獲得超9個贊

這是一個很難修復(fù)的錯誤。該修復(fù)程序已在Github PR上提交以供審查,以便 RTL 簽出并做出貢獻(xiàn)。

https://i.stack.imgur.com/QGbVA.gif

總之,開發(fā)人員使用二分搜索算法來查找用戶點(diǎn)擊了哪個字母。二進(jìn)制搜索方法假設(shè)單詞的后半部分總是在右邊。這與 RTL 語言相反,因?yàn)楣ぷ鞯暮蟀氩糠衷谧髠?cè)。這是我如何制作修復(fù)原型的片段:

 let characterIndex = 0;

    {

      let low = 0;

      let high = containingTextNode.length - 1;

      while (low <= high) {

        const charIndex = low + ((high - low) >> 1);

        const nextCharIndex = isPairedCharacter(

          containingTextNode.textContent,

          charIndex

        )

          ? charIndex + 2

          : charIndex + 1;


        const rangeRect = clientRectForRange(

          containingTextNode,

          charIndex,

          nextCharIndex

        );

        if (targetClientLeft < rangeRect.left && !rtl) {

          high = charIndex - 1;

          characterIndex = Math.max(0, charIndex - 1);

        } else if (targetClientLeft > rangeRect.right && !rtl) {

          low = nextCharIndex;

          characterIndex = Math.min(

            containingTextNode.textContent.length,

            nextCharIndex

          );

        } else if (targetClientLeft > rangeRect.right && rtl) {

          high = charIndex - 1;

          characterIndex = Math.max(0, charIndex - 1);

        } else if (targetClientLeft < rangeRect.left && rtl) {

          low = nextCharIndex;

          characterIndex = Math.min(

            containingTextNode.textContent.length,

            nextCharIndex

          );

        } else {

          if (!rtl){

            if (targetClientLeft <= (rangeRect.left + rangeRect.right) / 2) {

              characterIndex = charIndex;

            } else {

              characterIndex = nextCharIndex;

            }

          }else{

            if (targetClientLeft <= (rangeRect.left + rangeRect.right) / 2) {

              characterIndex = nextCharIndex;

            } else {

              characterIndex = charIndex;

            }

          }

          break;

        }

      }

    }

不幸的是,此代碼仍然缺少一些功能,例如在同一行中處理 RTL 和 LTR 內(nèi)容以及其他小錯誤。應(yīng)該做更多的工作并且合作是開放的,請為此 PR 做出貢獻(xiàn)。



查看完整回答
反對 回復(fù) 2022-10-13
  • 1 回答
  • 0 關(guān)注
  • 106 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號