samhocevar / emoji.wpf

😸 Emoji support for WPF
Do What The F*ck You Want To Public License
369 stars 43 forks source link

RichTextBox.Text ignores newline #67

Open v1km4n opened 1 year ago

v1km4n commented 1 year ago

RichTextBox input looks like this: image

RichTextBox.Text ignores newline and returns this: image

Using TextRange(RichTextBox.Document.ContentStart, RichTextBox.Document.ContentStart).text (the usual method for extracting RichTextBox text) ignores all the emojis and returns this: image Which is understandable since TextRange probably doesn't support emoji at all

I wasn't able to find any workarounds, so please tell me if there is any, but as of now it just looks like newline is ignored completely

Swindler95 commented 1 year ago

Hi,

I modified the class "TextSelection" to take into account the new lines :

case TextPointerContext.EmbeddedElement:
  var nextInsertionPosition = p.GetNextInsertionPosition(LogicalDirection.Forward);
  if (nextInsertionPosition != null && new TextRange(p, nextInsertionPosition).Text.Contains(Environment.NewLine))
    buf.AppendLine();
  break;