Skip to content

No "Search in page" possibility on embedded help on Linux/Webkit #1890

@iloveeclipse

Description

@iloveeclipse

Basically this is mostly same as https://bugs.eclipse.org/bugs/show_bug.cgi?id=577398.

AS of today (4.36 RC2), "Search in page" (something like Ctrl+F) is not available for help pages content shown by embedded Eclipse help browser on Linux/Webkit. On Windows/Edge "Ctrl+F" is working.

I'm not looking for a perfect solution and possibility to somehow add Ctrl+F to Webkit (which is most likely not possible for SWT at all), but for a practical solution that would allow users to search in page either via extra menu or button somewhere in the help page browser opened via the platform "Help Contents".

So it might be an SWT based solution (like extra "Find" context menu for browser page) or platform (Help UI) based (like extra button on Help UI somewhere), don't care.

The point is that user should be able to search in the page somehow.

Note: this javascript snippet does the job (I'm pretty sure there are more ways to achieve the same), so a possible menu or button could eventually define and call the javascript function:

function highlightText(searchText) {
  if (!searchText) return;
  const regex = new RegExp(searchText, 'gi');
  const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
  let node;
  while ((node = walker.nextNode())) {
    if (node.nodeValue.match(regex)) {
      const span = document.createElement('span');
      span.style.backgroundColor = 'yellow';
      span.innerHTML = node.nodeValue.replace(regex, match => `<mark>${match}</mark>`);
      node.parentNode.replaceChild(span, node);
    }
  }
}
// Usage:
highlightText('some text');

Metadata

Metadata

Assignees

Labels

LinuxHappens on LinuxbugSomething isn't workinghelp wantedExtra attention is neededusability

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions