mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibWeb: Insert newlines at <br> and block boundaries in copied text :^)
To make the plain text we copy out from LibWeb look at least somewhat like its original form, let's insert newlines at <br> elements and when we exit a block-level element. This is far from perfect, but seems to work pretty okay.
This commit is contained in:
parent
f7ef6c65b4
commit
ccdaa1bea9
Notes:
sideshowbarker
2024-07-19 05:12:00 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/ccdaa1bea92
1 changed files with 4 additions and 0 deletions
|
@ -46,6 +46,7 @@
|
|||
#include <LibWeb/Frame/EventHandler.h>
|
||||
#include <LibWeb/Frame/Frame.h>
|
||||
#include <LibWeb/Layout/LayoutDocument.h>
|
||||
#include <LibWeb/Layout/LayoutBreak.h>
|
||||
#include <LibWeb/Layout/LayoutNode.h>
|
||||
#include <LibWeb/Layout/LayoutText.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
|
@ -141,6 +142,9 @@ String PageView::selected_text() const
|
|||
while (layout_node && layout_node != selection.end().layout_node) {
|
||||
if (is<LayoutText>(*layout_node))
|
||||
builder.append(to<LayoutText>(*layout_node).text_for_rendering());
|
||||
else if (is<LayoutBreak>(*layout_node) || is<LayoutBlock>(*layout_node))
|
||||
builder.append('\n');
|
||||
|
||||
layout_node = layout_node->next_in_pre_order();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue