tongwentang / tongwentang-extension

MIT License
132 stars 15 forks source link

Problems in textarea inputting #10

Closed billzt closed 3 years ago

billzt commented 3 years ago

If a website has been set to auto-conversion, it is extremely difficult to type Chinese into the textarea in the website since the curses would keep jumping everywhere.

OS: Win7 Browser: Firefox 87.0 Input Method: https://pinyin.thunisoft.com

t7yang commented 3 years ago

Fix this issue could be hard 🤪 I can not simply reject or skip certain tags like input / textarea while walking through nodes, cause many websites use other elements to build their own input area. 😑

billzt commented 3 years ago

Fix this issue could be hard 🤪 I can not simply reject or skip certain tags like input / textarea while walking through nodes, cause many websites use other elements to build their own input area. 😑

However this bug only appears in the new 2.0 version

t7yang commented 3 years ago

Fix this issue could be hard 🤪 I can not simply reject or skip certain tags like input / textarea while walking through nodes, cause many websites use other elements to build their own input area. 😑

However this bug only appears in the new 2.0 version

Yes/No, if you disabled "Dynamic Convert" then this issue is gone.

billzt commented 3 years ago

Thank you, but I have to try on next Monday.

NightOwlElena commented 3 years ago

I have same issue with text input area as well, gmail in my case. Cursor will reset to the beginning of line after auto-convert is triggered I believe. Disabling Auto Convert per domain will "fix" it but it makes one of the key features unusable sadly.

Browser: Brave Version 1.22.71 Chromium: 89.0.4389.114 (Official Build) (x86_64)

yaoziyuan commented 3 years ago

Look at my Chrome extension "Phonetically Intuitive English" () for how to skip textarea, contentEditable elements and the like: https://sites.google.com/site/phoneticallyintuitiveenglish/

Specifically, it uses such code:

        if (
            node.parentNode
            && node.parentNode.isContentEditable==false
            && /^textarea$|^script$|^noscript$|^style$|^title$|^#cdata-section$|^#comment$|^option$/i.test(node.parentNode.nodeName)==false
            && node.nodeType==3 // is a text node
            && /^\s*$/.test(node.nodeValue)==false
            && /^gbqfs|^nopie|^collapseButton|^NavToggle/.test(node.parentNode.id)==false // not google front page buttons, "Word Translator" UI elements, Wikipedia toggles
            && (/^div$|^span$/i.test(node.parentNode.nodeName)==false || isHidden(node.parentNode)==false)
            //&& (/^div$|^span$/i.test(node.parentNode.nodeName)==false || node.parentNode.offsetWidth>0)
        ) {
t7yang commented 3 years ago

@yaoziyuan Yes, I have the same idea to reject all node with a contenteditable attribute.

tengjack commented 3 years ago

I can repro the bug in Gmail as well. And I'm not typing Chinese, only English. If "Dynamic Update" is turned off then the issue is fixed.

t7yang commented 3 years ago

close #10 by https://github.com/tongwentang/tongwen-core/commit/5fdbd5be3d1b2fa31b4ce3ea35e652caa724abb3