mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:58:12 +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/DateTime.h>
|
||||||
#include <LibCore/StandardPaths.h>
|
#include <LibCore/StandardPaths.h>
|
||||||
#include <LibGfx/ImageFormats/PNGWriter.h>
|
#include <LibGfx/ImageFormats/PNGWriter.h>
|
||||||
|
#include <LibWeb/Infra/Strings.h>
|
||||||
#include <LibWebView/ViewImplementation.h>
|
#include <LibWebView/ViewImplementation.h>
|
||||||
|
|
||||||
namespace WebView {
|
namespace WebView {
|
||||||
|
@ -128,6 +129,14 @@ DeprecatedString ViewImplementation::selected_text()
|
||||||
return client().get_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()
|
void ViewImplementation::select_all()
|
||||||
{
|
{
|
||||||
client().async_select_all();
|
client().async_select_all();
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
void set_preferred_color_scheme(Web::CSS::PreferredColorScheme);
|
void set_preferred_color_scheme(Web::CSS::PreferredColorScheme);
|
||||||
|
|
||||||
DeprecatedString selected_text();
|
DeprecatedString selected_text();
|
||||||
|
Optional<String> selected_text_with_whitespace_collapsed();
|
||||||
void select_all();
|
void select_all();
|
||||||
|
|
||||||
void get_source();
|
void get_source();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue