Copy paragraph styles in rich text, and make plain text clipboard work in web version again

This commit is contained in:
Yousef Khadadeh 2025-11-11 22:21:25 +03:00
parent b8fb00e218
commit 8830386dc0
4 changed files with 37 additions and 24 deletions

View file

@ -376,6 +376,12 @@ TextPosition TextBox::insert_rich_text(TextPosition p, const TextData& richText)
set_text_style_modifier_between(shiftedModPos, lastPos, modifier);
}
for(size_t pIndex = p.fParagraphIndex; pIndex <= lastPos.fParagraphIndex; pIndex++) {
// If the first line was empty before pasting (it's not empty right now, which is why the comparison is required), we will apply the paragraph style to the first line as well
if((pIndex == p.fParagraphIndex && paragraphs[pIndex].text.size() == richText.paragraphs[0].text.size()) || pIndex != p.fParagraphIndex)
paragraphs[pIndex].pStyleData = richText.paragraphs[pIndex - p.fParagraphIndex].pStyleData;
}
inputChangedTextBox = true;
needsRebuild = true;