mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
LibWebView: Add a helper to get selected text with collapsed whitespace
This commit is contained in:
parent
e221b3afeb
commit
6af279a22d
Notes:
sideshowbarker
2024-07-17 07:20:49 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/6af279a22d Pull-request: https://github.com/SerenityOS/serenity/pull/21566
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();
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
void set_preferred_color_scheme(Web::CSS::PreferredColorScheme);
|
||||
|
||||
DeprecatedString selected_text();
|
||||
Optional<String> selected_text_with_whitespace_collapsed();
|
||||
void select_all();
|
||||
|
||||
void get_source();
|
||||
|
|
Loading…
Reference in a new issue