@@ -778,13 +778,10 @@ private void ClearStyle(ITextRange range, bool monospace)
778778
779779 range . SetRange ( start , end ) ;
780780
781- if ( range . CharacterFormat . Size != 10.5f )
782- {
783- InsertBlockquote ( range , true , false ) ;
784- }
785-
786781 range . CharacterFormat = Document . GetDefaultCharacterFormat ( ) ;
787- //range.ParagraphFormat = Document.GetDefaultParagraphFormat();
782+ range . ParagraphFormat . SpaceAfter = 0 ;
783+ range . ParagraphFormat . SpaceBefore = 0 ;
784+ range . ParagraphFormat . SetIndents ( 0 , 0 , 0 ) ;
788785
789786 range . GetText ( TextGetOptions . NoHidden , out string text ) ;
790787 range . SetText ( TextSetOptions . Unlink , text ) ;
@@ -1256,7 +1253,9 @@ private bool GetIsEmpty()
12561253 try
12571254 {
12581255 Document . Selection . CharacterFormat = Document . GetDefaultCharacterFormat ( ) ;
1259- Document . Selection . ParagraphFormat = Document . GetDefaultParagraphFormat ( ) ;
1256+ Document . Selection . ParagraphFormat . SpaceAfter = 0 ;
1257+ Document . Selection . ParagraphFormat . SpaceBefore = 0 ;
1258+ Document . Selection . ParagraphFormat . SetIndents ( 0 , 0 , 0 ) ;
12601259 }
12611260 catch
12621261 {
@@ -1671,7 +1670,9 @@ public void InsertBlockquote(ITextRange textRange, bool enable, bool batch = tru
16711670 else
16721671 {
16731672 range . CharacterFormat . Size = 14 * magic ;
1674- range . ParagraphFormat = Document . GetDefaultParagraphFormat ( ) ;
1673+ range . ParagraphFormat . SpaceAfter = 0 ;
1674+ range . ParagraphFormat . SpaceBefore = 0 ;
1675+ range . ParagraphFormat . SetIndents ( 0 , 0 , 0 ) ;
16751676 }
16761677
16771678 MergeParagraphs ( range ) ;
@@ -1821,14 +1822,17 @@ private void UpdateFormat()
18211822 }
18221823 }
18231824
1824- if ( range . ParagraphFormat . SpaceAfter != 0 && range . CharacterFormat . Size != 9 )
1825+ if ( range . ParagraphFormat . SpaceAfter == 6 && range . CharacterFormat . Size != 9 )
18251826 {
18261827 range . CharacterFormat . Size = 9 ;
18271828 }
1828- else if ( range . ParagraphFormat . SpaceAfter == 0 && range . CharacterFormat . Size != 10.5f )
1829+ else if ( range . ParagraphFormat . SpaceAfter != 6 && range . CharacterFormat . Size != 10.5f )
18291830 {
18301831 range . CharacterFormat . Size = 10.5f ;
18311832 }
1833+
1834+ range . Collapse ( false ) ;
1835+
18321836 } while ( range . MoveStart ( TextRangeUnit . CharacterFormat , 1 ) > 0 ) ;
18331837
18341838 //EndUndoGroup();
@@ -1864,14 +1868,6 @@ private void UpdateBlocks()
18641868
18651869 lastPosition = range . StartPosition ;
18661870
1867- if ( range . StartPosition == 0 )
1868- {
1869- //ContentElement.Padding = new Thickness(48, range.ParagraphFormat.SpaceAfter == 0 ? 13 : 7, 0, 15);
1870- ContentElement . Padding = new Thickness ( 0 , 13 , 0 , 15 ) ;
1871- //ContentElement.Margin = new Thickness(0, range.ParagraphFormat.SpaceAfter == 0 ? 0 : 0, 0, 0);
1872- //Blocks.Padding = new Thickness(0, range.ParagraphFormat.SpaceAfter == 0 ? 0 : 0, 0, 0);
1873- }
1874-
18751871 if ( range . ParagraphFormat . SpaceAfter != 0 )
18761872 {
18771873 range . GetRect ( PointOptions . None , out Rect rect , out _ ) ;
@@ -1915,7 +1911,7 @@ private void ContentElement_ViewChanged(object sender, ScrollViewerViewChangedEv
19151911 if ( Blocks != null )
19161912 {
19171913 Blocks . Height = ContentElement . ExtentHeight ;
1918- Blocks . Margin = new Thickness ( 0 , - 6 , 0 , Math . Min ( 0 , ActualHeight - ContentElement . ExtentHeight ) ) ;
1914+ Blocks . Margin = new Thickness ( 0 , 0 , 0 , Math . Min ( 0 , ActualHeight - ContentElement . ExtentHeight ) ) ;
19191915 }
19201916 }
19211917
@@ -1935,8 +1931,10 @@ private void OnPreviewKeyDown(object sender, KeyRoutedEventArgs e)
19351931
19361932 range . SetText ( TextSetOptions . None , "\r " ) ;
19371933 range . SetRange ( range . StartPosition + direction , range . StartPosition + direction ) ;
1938- range . ParagraphFormat = Document . GetDefaultParagraphFormat ( ) ;
19391934 range . CharacterFormat = Document . GetDefaultCharacterFormat ( ) ;
1935+ range . ParagraphFormat . SpaceAfter = 0 ;
1936+ range . ParagraphFormat . SpaceBefore = 0 ;
1937+ range . ParagraphFormat . SetIndents ( 0 , 0 , 0 ) ;
19401938 Document . Selection . SetRange ( range . StartPosition + direction , range . StartPosition + direction ) ;
19411939
19421940 EndUndoGroup ( ) ;
0 commit comments