mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:58:13 +00:00
LibWebView: Add a helper to get selected text with collapsed whitespace
This commit is contained in:
parent
e221b3afeb
commit
6af279a22d
2 changed files with 10 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <LibCore/DateTime.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibGfx/ImageFormats/PNGWriter.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
#include <LibWebView/ViewImplementation.h>
|
||||
|
||||
namespace WebView {
|
||||
|
@ -128,6 +129,14 @@ DeprecatedString ViewImplementation::selected_text()
|
|||
return client().get_selected_text();
|
||||
}
|
||||
|
||||
Optional<String> ViewImplementation::selected_text_with_whitespace_collapsed()
|
||||
{
|
||||
auto selected_text = MUST(Web::Infra::strip_and_collapse_whitespace(this->selected_text()));
|
||||
if (selected_text.is_empty())
|
||||
return OptionalNone {};
|
||||
return selected_text;
|
||||
}
|
||||
|
||||
void ViewImplementation::select_all()
|
||||
{
|
||||
client().async_select_all();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue