Skip to content
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

[Question] Output suggestion list like languagetool.org demo #13

Open
bi1101 opened this issue Dec 31, 2023 · 5 comments
Open

[Question] Output suggestion list like languagetool.org demo #13

bi1101 opened this issue Dec 31, 2023 · 5 comments

Comments

@bi1101
Copy link

bi1101 commented Dec 31, 2023

Hi @KnowZero ,

I found great value in your repo and am very grateful that you open-source such a project!

I have two questions:

  1. How can I display suggestion lists in a side panel that interacts with underlined text, similar to the languagetool.org demo?
  2. How can I integrate suggestions from another API like OpenAI (for writing style suggestions) with a unique underline color?

Could you guide me on these?

Thanks!

@KnowZero
Copy link
Owner

The words should be in the LT.highlightList, the logic of connecting is split out with TinyMCE integration, so you can pull the data in LT in style it how you want

Within the current plugin, you would have to do a bit of work of formatting the OpenAI data to match the output format of LanguageTool and merge them. Then create another lt_setHighlight type and set up css for that type

@bi1101
Copy link
Author

bi1101 commented Jan 13, 2024

Thank you @KnowZero !

@bi1101
Copy link
Author

bi1101 commented Jan 13, 2024

Can you explain a bit about which part of the code is responsible for LT.highlightList?

I've been messing with the repo for over a week and ended up with a different direction which is not optimal

@KnowZero
Copy link
Owner

KnowZero commented Jan 14, 2024

The library is divided into 2,

plugin and include/languagetool

The include/languagetool is a generic wrapper around languagetool and loads up all the common features. The plugin is a wrapper for tinymce that uses the data

Since the library is generic, it can be used outside tinymce like ck.html does for ckeditor

So back to the point, what you would do is modify the plugin.min.js which contains the tinymce bindings

 var LT = new LanguageTool(tinymce.activeEditor.settings,$);

is what loads up the generic library into LT variable

So you can either build your own like ck.html does or modify plugin.min.js. There you can access the LT variable to get all the data you need will be there.

Here is a most basic version without any editor and just using contenteditable to demonstrate how the generic library works:

https://jsfiddle.net/kafnscte/

@bi1101
Copy link
Author

bi1101 commented Jan 15, 2024

Thanks a lot for the guidance! The details and the jsFiddle example you provided are super helpful. I'll dive into it right away. Really appreciate your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants