You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2013/10/16 21:44:07 UTC

git commit: [flex-sdk] [refs/heads/release4.11.0] - handle newlines when pasting into a non-multiline RET

Updated Branches:
  refs/heads/release4.11.0 cbd143c02 -> ffdd6f706


handle newlines when pasting into a non-multiline RET


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/ffdd6f70
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/ffdd6f70
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/ffdd6f70

Branch: refs/heads/release4.11.0
Commit: ffdd6f706e64360ea863e471075afc1f42e6098c
Parents: cbd143c
Author: Alex Harui <ah...@apache.org>
Authored: Wed Oct 16 12:42:49 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Wed Oct 16 12:42:49 2013 -0700

----------------------------------------------------------------------
 .../src/spark/components/RichEditableText.as    | 23 +++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/ffdd6f70/frameworks/projects/spark/src/spark/components/RichEditableText.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/RichEditableText.as b/frameworks/projects/spark/src/spark/components/RichEditableText.as
index e3b8319..5746175 100644
--- a/frameworks/projects/spark/src/spark/components/RichEditableText.as
+++ b/frameworks/projects/spark/src/spark/components/RichEditableText.as
@@ -48,6 +48,7 @@ package spark.components
     import flashx.textLayout.edit.IEditManager;
     import flashx.textLayout.edit.ISelectionManager;
     import flashx.textLayout.edit.SelectionState;
+    import flashx.textLayout.edit.TextClipboard;
     import flashx.textLayout.elements.Configuration;
     import flashx.textLayout.elements.GlobalSettings;
     import flashx.textLayout.elements.InlineGraphicElement;
@@ -4743,7 +4744,27 @@ package spark.components
                 // Paste is implemented in operationEnd.  The basic idea is to allow 
                 // the paste to go through unchanged, but group it together with a 
                 // second operation that modifies text as part of the same 
-                // transaction. This is vastly simpler for TLF to manage. 
+                // transaction. This is vastly simpler for TLF to manage.
+                // But first, we do a multi-line check and remove newlines if not
+                if (!multiline)
+                {
+                    var po:PasteOperation = PasteOperation(op);
+                    
+                    // If copied/cut from displayAsPassword field the pastedText
+                    // is '*' characters but this is correct.
+                    var pastedText:String = staticPlainTextExporter.export(
+                        po.textScrap.textFlow, ConversionType.STRING_TYPE) as String;
+                    
+                    // If there are no newlines there is nothing
+                    // more to do.
+                    if (pastedText.search(ALL_NEWLINES_REGEXP) != -1)
+                    {
+                        pastedText = pastedText.replace(ALL_NEWLINES_REGEXP, "");
+                        po.textScrap = 
+                            TextClipboard.importToScrap(pastedText, po.textScrap.isPlainText() ?
+                                TextConverter.PLAIN_TEXT_FORMAT : TextConverter.TEXT_LAYOUT_FORMAT);
+                    }
+                }
             }
             else if (op is DeleteTextOperation || op is CutOperation)
             {