ssborbis / ContextSearch-web-ext

Search engine manager for modern browsers
315 stars 35 forks source link

Feature request: Multi-line selection opens multi-line search #472

Open dnknn opened 2 years ago

dnknn commented 2 years ago

Hi✿(◕‿◕)✿! Only an example can describe the feature :)

Obviously, this has 4 lines (\n) of text. Multi-line Keyword1\nMulti-line Keyword2\nMulti-line Keyword3\nMulti-line Keyword4


dnknn commented 2 years ago

update edited :)

ssborbis commented 2 years ago

There's a hidden option in the release I just dropped ( 1.38 ) called multilinesAsSeparateSearches. If you enable that, it will treat multi-lines as separate search terms. Right now, it only works from the context menu, but it's there. I'll get something more robust when I have time.

ssborbis commented 2 years ago

Actually, I don't think that change made it to the new release. It is in the repo, however.

dnknn commented 2 years ago

@ssborbis Hi, add sub-options of this advanced option, Do you think it is necessary?

Of course, don't worry, just let you know. :)

For example: userOptions.splitMultilineAmount

<input type="number" min="5" max="50" step="1" id="splitMultilineAmount">
if ( searchTerms.split('\n').length > userOptions.splitMultilineAmount )    {
    alert(`Exceeds the set number of lines !`);
    return;
}
dnknn commented 2 years ago

Hi @ssborbis

There's a hidden option in the release I just dropped ( 1.38 ) called multilinesAsSeparateSearches. If you enable that, it will treat multi-lines as separate search terms. Right now, it only works from the context menu, but it's there. I'll get something more robust when I have time.

Since there is no UI option, I manually enable it in the Console userOptions.multilinesAsSeparateSearches = true defaultUserOptions.multilinesAsSeparateSearches = true

224_12093755

Then I tested and found that the function does not work 😭-_-😢

Also, would like to ask when will this feature be added to the UI options?

ssborbis commented 2 years ago

It won't work in the release ( 1.38 ). It should be working from the code in the development repo, however.

I'll post a beta you can test.

ssborbis commented 2 years ago

Since there is no UI option, I manually enable it in the Console

You can do that or manually edit the preferences JSON from here. edit

ssborbis commented 2 years ago

https://github.com/ssborbis/ContextSearch-web-ext/releases/download/v1.39b2/contextsearch_web_ext-1.39b2-an+fx.xpi

dnknn commented 2 years ago

@ssborbis Version V1.39(CWS version) still doesn't work -_-

I use the Chrome browser and installed the latest version V1.39 on the CWS store. then manually edit the preferences JSON, Save, but still doesn't work... Whether it's the context menu or other search methods, multilinesAsSeparateSearches still doesn't work, -_- I don't know why. 224_15180703

ssborbis commented 2 years ago

Do you have an example webpage where it's not working? I've been using a simple test page and I've tested in textarea fields and with <br> tags as newlines and it is working in chromium.

I did notice the "Cancel" button isn't working if you get prompted for being over the limit. I have that fixed in the repo.

dnknn commented 2 years ago

Do you have an example webpage where it's not working?

🤝ThankS! Now it works! the principle needs to restart the browser to work.


@ssborbis Now I also found another problem for the new version: 1) text selection getSelection() 2) Then start ContextSearch, the search box is automatically populated with getSelection(), right? 3) ContextMenu and QuickMenu are fine. no problem

4) But the startup of these two places cannot be automatically filled in getSelection(). Problem/Bug

In fact, this problem is similar to insensitivity. In most cases, it will not be automatically filled, or it needs to be restarted(click again) repeatedly to be automatically filled.

I don't know why, or what code you changed, the previous 1.28/1.29 versions were perfect, never had this problem.

Similar question I reported a long time ago: https://github.com/ssborbis/ContextSearch-web-ext/issues/361

ssborbis commented 2 years ago

Does this problem happen when multilinesAsSeparateSearches = false ?

dnknn commented 2 years ago

Does this problem happen when multilinesAsSeparateSearches = false ?

exactly the same, has nothing to do with multilinesAsSeparateSearches

ssborbis commented 2 years ago

This may be related to the issue of editing the search bar in the qm is not updating the search terms in the actual search.

I have that fixed, and I tested the problem of selected text not populating the toolbar and sidebar menus when they are opened, and it seems to be working normally.

Updates are in the dev repo, if you're able to test.

ssborbis commented 2 years ago

I tested the problem of selected text not populating the toolbar and sidebar menus when they are opened, and it seems to be working normally.

Correction. It seems to be working only some of the time. I'll dig around and try to find why that is.

ssborbis commented 2 years ago

Ok, you can try what's in the dev repo to see if it works for you. For some reason I don't understand, chromium-based browsers require a slight delay in setting the search bar value to the search terms, as seen by getSelection(). I'm currently using a 10ms delay, and seem to get the correct selected text in the search bar 10/10 times.

dnknn commented 2 years ago

chromium-based browsers require a slight delay in setting the search bar value to the search terms, as seen by getSelection(). I'm currently using a 10ms delay, and seem to get the correct selected text in the search bar 10/10 times.

thanks for your hard working! I tested it and found it to be perfect, and I didn't find the problem of not filling or not updating the filling.

ssborbis commented 1 year ago

v1.41.1 is out. I'm not sure this fix made it into a release before now. Let me know if this is working correctly, or just close out the issue, and I'll assume it is.

ssborbis commented 1 year ago

How often are you using this feature? I wonder if it wouldn't be useful to make this standard behavior, but prompt with a yes/no confirmation dialog if the search terms are multiline.