mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
LibWebView: Add a helper to get selected text with collapsed whitespace
This commit is contained in:
committed by
Andreas Kling
parent
e221b3afeb
commit
6af279a22d
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user