KnowZero / tinymce4-languagetool

Attempt to port Language Tool Spelling and Grammar Check to TinyMCE 4 [ALPHA/EXPIREMENTAL]
Apache License 2.0
22 stars 11 forks source link

Help request and question #9

Open leknoppix opened 2 years ago

leknoppix commented 2 years ago

Hello

I have a problem.

I'm trying to figure out how your script works for ckeditor. In my test phase (ck.html file), I get an error: Uncaught TypeError: $ is not a function

I have the impression that, when loading the remote file https://knowzero.github.io/tinymce4-languagetool/languagetool/include/languagetool.min.js

The latter does not take into account the jquery previously loaded. I seek to understand your source code in order to translate it into pure javascript, without any third-party libraries

Could you tell me how to understand your code?

I thank you in advance.

leknoppix

NB: Sorry, my English is a bit rusty.

KnowZero commented 2 years ago

Hi, the issue is that the CKEditor was mostly used as an example for the flexibility of the languagetool js library, but I have not updated the CKEditor plugin example since demoing it.

To fix your issue, in the ck.html file, add the $ sign to the new LanguageTool deceleration as so: var LT = new LanguageTool( editor.config, $ );

and add:

LT.setFunction('window',function () {
return editor.window;
});

This should make it work properly.

And yes, at the time browser support was terrible and I was lazy so I opted for jquery. I was planning to eventually rewrite the whole thing without jquery as vanilla, but the project I needed to use languagetool for got delayed and I never got around to doing it.

leknoppix commented 2 years ago

Hello and thank you for this answer.

I set it up locally. I will try to translate the jquery code to vanilla javascript

I still have some errors, I feel that despite disabling scayt, I get new errors:

GEThttps://loader.webspellchecker.net/sproxy_fck/sproxy.php?plugin=fck2&customerid=1:ua3xw1-2XyGJ3-GWruD3-6OFNT1-oXcuB1-nR6Bp4-hgQHc-EcYng3-sdRXG3-NOfFk&cmd=script&doc=wsc&schema=22
[HTTP/2 403 Forbidden 413ms]

and

Uncaught ReferenceError: DefaultParams is not defined

I continue to do my research because for the project that I am in progress, I would like to couple my wysiwyg with a mini spell checker.

I will come back, if you wish, to this topic to give news of progress, and of course, I will send you a pull request to your repository.

KnowZero commented 2 years ago

I uploaded the changes to ck.html, to confirm first does this work for you:

https://knowzero.github.io/tinymce4-languagetool/ck.html

Though to note if you plan to do a pull request with removal of jquery, you should test to make sure it works for TinyMCE4 as well. Generally it shouldn't be a problem and should work on both if you port it. That said, the TinyMCE4 version has extra features that were not yet set up for the CK version. Such as the bottom bar and the dialog. So that you don't get confused what the extra code is for in the js library.

leknoppix commented 2 years ago

Hello and thank you for coming back.

The modified ck.html code no longer has an error concerning the "$". I get, whether with my development code (my laptop) or yours (online version), the same error:

GEThttps://loader.webspellchecker.net/sproxy_fck/sproxy.php?plugin=fck2&customerid=1:ua3xw1-2XyGJ3-GWruD3-6OFNT1-oXcuB1-nR6Bp4-hgQHc-EcYng3-sdRXG3-NOfFk&cmd=script&doc=wsc&schema=22
[HTTP/2 403 Forbidden 413ms]

In my research, I found that it corresponded to another plugin named "wsc". Being pretty busy lately, I'll look a little later and analyze your code.

KnowZero commented 2 years ago

The weird thing is, I don't get that error. I tried both firefox and chromium and none get that error. Do you by chance have some sort of browser extension that may be interfering? Try with a private/incognito window that has no plugins and see if you get same result.

KnowZero commented 2 years ago

I think I know where the confusion lies!

You are clicking on the ABC spellcheck correct?(That is the ckeditor spellchecker) But that isn't how the demo works. The demo is set to spell check after every line or after you type a period, exclamation mark. Aka on the go.

If you want to configure it for manual spellchecking, check the tinymce example for config options. Same if you want to do dialog spellchecking. There is also option to have it on the go spellcheck after every word.

KnowZero commented 2 years ago

@leknoppix - Since a month has passed, can I consider this issue addressed and close the issue?