face-hh / fextify

A simple text editor written in Rust using Tauri, inspired by Obsidian.
Apache License 2.0
197 stars 14 forks source link

fix(main): fixed language specific characters for a subset of languages #27

Closed MemerGamer closed 10 months ago

MemerGamer commented 10 months ago

With this change you can write in the title and in the editor language specific characters in the following languages: English, French, German, Spanish, Portuguese, Russian, Chinese (Simplified), Japanese, Korean, Polish, Hungarian, Romanian

Example: I can write "hálás" ( a word in Hungarian meaning grateful ), or I can write the word "recunoscător" ( which means the same in Romanian ) in the title or in the editor. This will help people to take notes in their native languages

I even tested it with Anthy Japanese and it works great

Polygons1 commented 10 months ago

Command pallet isn't working... (I am on macOS btw)

MemerGamer commented 10 months ago

Command pallet isn't working... (I am on macOS btw)

Could you send me some logs maybe? I will look into it later today

Polygons1 commented 10 months ago

where are they?

btw, CMD+n, CMD+o isn't working too

but CMD+w is working

Polygons1 commented 10 months ago

and in your PR, window.animateDiv is null...

MemerGamer commented 10 months ago

I will look into it today thank you for testing it on macOS

Polygons1 commented 10 months ago

I debugged it, and the body keydown event isn't getting executed

Polygons1 commented 10 months ago

I debugged it, and the real event is inside originalEvent

Polygons1 commented 10 months ago

just change .keydown((e) => { to .keydown(({originalEvent: e})=> {

MemerGamer commented 10 months ago

just change .keydown((e) => { to .keydown(({originalEvent: e})=> {

Thank you so much, I will change that and test it, when I get home

Polygons1 commented 10 months ago

you don't need, I just saw that this is already in the constructor lol

Polygons1 commented 10 months ago

its actually the window.animateDiv that don't end up in window, because something stopping the execution of the code

Polygons1 commented 10 months ago

My debug is pointing to those 2 functions:

window.title.val(decodeURIComponent(info[0])); editor.setData(info[1]);

MemerGamer commented 10 months ago

My debug is pointing to those 2 functions:

window.title.val(decodeURIComponent(info[0])); editor.setData(info[1]);

I see that makes sense, it is a weird scenerio where I needed to use them while I was working on the title. I will debug and fix this today

MemerGamer commented 10 months ago

So the current problem is that, if we check the event with jQuery the language specific characters doesn't get to the event handler, so we can't write those characters in the title. But it doesn't blocks the hotkey shortcut handler to recognize them.

The version that I did with JavaScript is the opposite, it captures all the input, even the hotkeys, so that is way the hotkeys didn't worked.

Man you gotta love Javascript :)

I will try to think of a solution, but I tought that this issue could appear somewhere else, so I'm probably going to rewrite this handler in jQuery (since most of the code is written with that) and we will see how it will work out.

Polygons1 commented 10 months ago

for me it stopped the execution... I debugged it with console.logs and after those lines, nothing was executing

MemerGamer commented 10 months ago

for me it stopped the execution... I debugged it with console.logs and after those lines, nothing was executing

Yes because the event handler captured the "change" and blocked the code. One temporary solution could be for me to change the code like this:

...
window.title.on("input", async () => {
  const encodedTitle = encodeURIComponent(window.title.val());

  save_title(window.path, encodedTitle);
  manage_tabs(await get_tabs());

  window.path = encodedTitle;
});
...

This way we could write in our edit in our native languages but we cant write language specific characters to the title like "á" for example, but we would get our hotkeys back.

I wil make a commit with this change and I will try to fix the title issue

Polygons1 commented 10 months ago

btw for the keys you can use e.code

Polygons1 commented 10 months ago

W it's working now!

MemerGamer commented 10 months ago

Contributor

Yes, except the title, but when I will have time, I will fix that as well