-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
On input for Itext #2352
On input for Itext #2352
Conversation
update to master
@asturur Great job! I test it in windows8.1 chrome 64bit. |
i got it i have to compare text lengths. i think same for japanese |
@sapics multiple chars should be ok now. |
@kangax ready for review. |
textLength = this.text.length, | ||
newTextLength = this.hiddenTextarea.value.length, | ||
diff = newTextLength - textLength, | ||
insChar = this.hiddenTextarea.value.slice(cp, cp + diff); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insChar
→ charsToInsert
@kangax changes applied |
LGTM, just need a confirmation that it works! /cc @sapics |
@sapics if i use input method japanese, do you think i can emulate your settings/situation? we did a step further anyway is lot better than before. |
@asturur I think that yes you can! |
@sapics your example is perfect. |
@sapics but do you expect Right to Left writing when using the japanese input? How this transformation works? |
@sapics http://www.deltalink.it/andreab/fabric/kitchensink.html @kangax i would pull as it is JUST for accent support and give JP and CHN input a later review. |
@asturur Great Job! Now, Japanese input works! |
the important thing is that it looks right. |
I'm afraid that this solution (detecting length change) is not robust enough, cuz for accent-based input methods, there's no relation between length changes and content changes, for example sometime's when user type one character, length might be still the same but contents inside it has changed, or with some input behavior the length will become shorter. In a word, Accent-based characters composing procedure has inner-states, the ultimate solution is this: https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent but it is not stable enough yet, however, currently there's something we can rely on: selection. The characters that are still in compositing will alwasy be selected, so what we need to do is just replace the contents in current selection of IText with the contents in current selection of Another issue is Actually if you have time, you may want to take a look at #2243, I've been through all those pitfalls when I implement this patch, includes the bug @sapics mentioned. Something might not make sense to you but I did all those tweaks for reasons. It's totally fine if you don't like my code and prefer to implement it from scratch, I'm just saying that don't fall into the same pitfalls again if it is avoidable. We've tested this patch on:
it works and especially works well with #1990 together cuz the options box will be placed properly. So I guess it is not totally useless. |
can you show some accent that are not gonna work with this solution? we totally understand that this solution does not work with the jpn and chn languages, for wich we planned a later review. i pushed it later because as of now best solution is to invert the text source. this.text = this.hiddenTextarea.value but requires too many changes now. i also replied to @sapics to his example a ka no + space "i have to trash this and do it differently". |
I just tried Fabric rc-1.6.0 with an IText, using latest Chrome browser on Win 7. I installed Hebrew, Arabic, Hindi and Russian keyboard layouts on Win 7 (built in ones, not 3rd party app). I found typing characters in languages which have multi byte characters/modifiers always adds an extra space on the end of the line after the actual characters you want, on the right hand side and also places the cursor there, but the typed characters get added in the right place. So this happens with Hindi for example which is written Left To Right. but not Russian as that is one character per key press . However with right-to-left languages such as Arabic and Hebrew, the typed characters get added simultaneously on the left hand side of the whole line whilst cursor and extra spaces still appear on the left (thus cursor and text entry point get further apart with each new character). Not sure if fix is planned for 1.6.0? Would be amazing to offer full international text entry! |
We need to rework quite lot of things to get full onInput support. |
+1 for Chinese input. |
Here seems to be a solution (http://jsfiddle.net/3jk3jvy7/light/), but I'm not sure how to apply it to Fabric.js. I'm using Fabric.js as part of Pixie. Could someone tell me how to apply the patch? |
you should download the attacched fabric.min.js, deminimize it, port the changes from 1.4.0 to 1.6.0 We had correctly working multibyte demo, but it was lacking style. |
@asturur could you share the fabric.js file where you had it working? I don't care about text styles, but it is very important that multi-byte text input works. |
because that patch has mixed input scenario with oninput and onkeypress. while we want to switch to oninput directly but we need to setup styles first and cursor position. |
The Android keyboard is still not pop-ing up when editing a iText object.
|
Hi @asturur, On Mac 10.9.5 this is what I get when using the kitchensink demo on chrome 49, Firefox 44 and Safari 9.0.1: Firefox: same as above Safari: Accents are placed twice; before and over the character: `à, ´é. Using the vanilla text input right bellow the canvas works as expected. |
We changed quite a bit of things on text input lately ( we switched to oninput event) did you try latest version from thw github repository? |
@asturur - great to hear text input developments - what's the main benefits/effects of these changes (e.g. oninput event). Also, how to get the latest version - where on these github pages is the right link please? (I don't use git). Many thanks |
Mainly accented letter should work evey os/language. I need to make an auto builder it would help many people.... |
@asturur thanks - how can I download latest version please, where is link on the github (i.e. this) site? |
can you share OS, browser, keyboard and input method? |
Mac Retina Mid 2012 with OSX 10.9.5 on chrome 49.0, Firefox 44 and Safari 9.0.1. The keyboard layout is US International. Also tried on a Mac OSX 10.11.13, with the same results. Firefox: same as above Safari: Accents are placed twice; before and over the character: `à, ´é. (this is the oddest one. One input generates two chars). This only happens if I try to edit directly at the canvas. If I use the execute function or use the vanilla text input, it renders perfectly. |
added to temp test page brilliant fix from #2820. http://www.deltalink.it/andreab/fabric/iphone.html Can you @angelim check if now accent works as expected? |
YES!!!!!! |
@asturur Copy from IText still not working in IE(11) and Edge. |
Also still practically impossible to write Japanese in IText. |
@asturur When using version 1.6.0-rc1 i had the exact same issue as @angelim (using Mac OS, keyboard Brazilian - Pro):
Then i tried your demo (http://www.deltalink.it/andreab/fabric/iphone.html) which solved the issue for @angelim, but in my case, both the demo and releases 1.6.0+, the new behavior is that when typing all three strokes cause an onkeydown event, key codes: ( it works ok on any textarea or input, it doesn't work on iText |
i noticed this regression on mac last week. o have to sit on a mac and check. any mac browser? |
This time, both safari and chrome have the exact same behavior. Tested on windows, and it works perfectly as it should. If there is anything i can do to help, like attaching prints of some console debugging, let me know |
@asturur can you reopen this issue? |
this was a pr, i cannot open again. Can you describe me the actual issue? what is not working with wich keyboard and operaring system browser. i m getting an apple notebook if it may help. |
Version 1.6.0-rc1When using version 1.6.0-rc1 i had the exact same issue as @angelim (using Mac OS, keyboard Brazilian - Pro, but i tested in many configurations that accept accents - spanish, italian, etc), as follows: Version 1.6.1+Then i tried your demo (http://www.deltalink.it/andreab/fabric/iphone.html) which solved the issue for @angelim, but in my case, both the demo and releases 1.6.0+, the new behavior is that when typing ´+a, i get the ´ but when pressing a, nothing happens (it stays ´). by pressing a again (second time) i get ´a (by typing ´+a+a, in total)
|
as soon as i have a mac, i will put myself on this. |
Thanks @asturur . I think one of the main issues and hopefully easiest to solve is when any multi-character alphabets are used, e.g. Arabic and many others, for each visual character that is typed or copy-pasted, an extra space appears so an itext starts looking like "ص|" (where | is the cursor) and as you type it is "صقفغ___ |" and then "صقفغغعارةتوخح________ |" (I've used _ underscore for a space here as this editor seems to delete them) with no way to remove that space. (on the subject of Arabic - and Hebrew etc - would be cool to be able to enter Right To Left (RTL) text, but that's a separate issue I guess!). Thanks, |
closes #2051
closes #2318
closes #1747
@sapics could you try to enter some japanese text?
@marcospassos can you try it
@angelim @taveras
demo here:
http://www.deltalink.it/andreab/fabric/kitchensink.html