Skip to content

Commit ebd4b95

Browse files
Update the changes
1 parent 467c6f8 commit ebd4b95

File tree

4 files changed

+177
-81
lines changed

4 files changed

+177
-81
lines changed

MAUI/Rich-Text-Editor/Basic-Features.md

Lines changed: 173 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,83 +11,237 @@ documentation: ug
1111

1212
This section covers the essential properties, methods, and events of the .NET MAUI `SfRichTextEditor` for handling content and user interactions.
1313

14-
## Handling Content
14+
## Setting Text
1515

16-
### Setting and Getting HTML Content
16+
The Rich Text Editor control displays the text/formatted text(HTML string) that can be set using the `Text` property.
1717

18-
The rich content of the editor, including all formatting, is accessible through the `Text` property. You can use this property to both load and retrieve the content as an HTML string.
18+
{% tabs %}
19+
20+
{% highlight xaml %}
21+
22+
<richtexteditor:SfRichTextEditor Text= "The &lt;b&gt; rich text editor &lt;/b&gt; component is WYSIWYG editor that provides the best user experience to create and update the content" />
23+
24+
{% endhighlight %}
25+
26+
{% highlight C# %}
27+
28+
SfRichTextEditor richTextEditor = new SfRichTextEditor();
29+
richtexteditor.Text = "The <b>rich text editor</b> component is WYSIWYG editor that provides the best user experience to create and update the content";
30+
31+
{% endhighlight %}
32+
33+
{% endtabs %}
34+
35+
## Retrieving HTML text
36+
37+
The formatted text of Rich Text Editor can be retrieved using the `HtmlText` property of `SfRichTextEditor`.
38+
39+
{% tabs %}
40+
41+
{% highlight C# %}
42+
43+
string HTMLText = richtexteditor.HtmlText;
44+
45+
{% endhighlight %}
46+
47+
{% endtabs %}
48+
49+
50+
## Getting Selected HTML
51+
52+
To retrieve the HTML representation of the currently selected content, use the `GetSelectedText` method.
53+
54+
{% tabs %}
55+
56+
{% highlight c# %}
57+
58+
string selectedText = await rte.GetSelectedText();
59+
60+
{% endhighlight %}
61+
62+
{% endtabs %}
63+
64+
## Default Text Style
65+
66+
You can define the default appearance for any new text typed into the editor. These settings apply to text that does not have any other specific formatting applied.
67+
68+
* `DefaultFontFamily`: Sets the default font family for the content.
69+
* `DefaultFontSize`: Sets the default font size.
70+
* `DefaultTextColor`: Sets the default color of the text.
71+
72+
{% tabs %}
73+
{% highlight xaml %}
74+
75+
<rte:SfRichTextEditor DefaultFontFamily="Impact"
76+
DefaultFontSize="14"
77+
DefaultTextColor="DarkGreen" />
78+
79+
{% endhighlight %}
80+
{% highlight c# %}
81+
82+
SfRichTextEditor richTextEditor = new SfRichTextEditor();
83+
richTextEditor.DefaultFontFamily = "Impact";
84+
richTextEditor.DefaultFontSize = 14;
85+
richTextEditor.DefaultTextColor = Colors.DarkGreen;
86+
87+
{% endhighlight %}
88+
{% endtabs %}
89+
90+
![.NET MAUI Rich Text Editor with Placeholder](images/richtexteditor-text.png)
91+
92+
93+
## Placeholder
94+
95+
The editor can display a `placeholder` text when the content is empty. This is useful for prompting the user. The placeholder is cleared as soon as the user starts typing.
96+
97+
* `PlaceholderFontFamily`: Sets the font family of the placeholder text.
98+
* `PlaceholderFontSize`: Sets the font size of the placeholder text.
99+
* `PlaceholderColor`: Sets the color of the placeholder text.
19100

20101
{% tabs %}
21102

22103
{% highlight xaml %}
23104

24-
<rte:SfRichTextEditor Text="The Syncfusion .NET MAUI Rich Text Editor is a WYSIWYG editor for creating and editing rich text content." />
105+
<rte:SfRichTextEditor Placeholder="Type your content here..."
106+
PlaceholderFontFamily="Impact"
107+
PlaceholderFontSize="24"
108+
PlaceholderColor="Green">
109+
</rte:SfRichTextEditor>
25110

26111
{% endhighlight %}
27112

28113
{% highlight c# %}
29114

30115
SfRichTextEditor richTextEditor = new SfRichTextEditor();
31-
richTextEditor.Text = "The Syncfusion .NET MAUI Rich Text Editor is a WYSIWYG editor for creating and editing rich text content.";
32-
this.Content = richTextEditor;
116+
richTextEditor.Placeholder = "Type your content here...";
117+
richTextEditor.PlaceholderFontFamily = "Impact";
118+
richTextEditor.PlaceholderFontSize = 24;
119+
richTextEditor.PlaceholderColor = Colors.Green;
120+
121+
{% endhighlight %}
122+
{% endtabs %}
123+
124+
![.NET MAUI Rich Text Editor with Placeholder](images/richtexteditor-placeholder.png)
125+
126+
127+
128+
## Programmatic Control
129+
130+
The `SfRichTextEditor` provides several methods to programmatically control its behavior, such as managing focus, history, and cursor position.
131+
132+
### Move Cursor to Start
133+
134+
Moves the cursor to the very beginning of the content in the editor.
135+
136+
{% tabs %}
137+
138+
{% highlight c# %}
139+
140+
richTextEditor.MoveCursorToStart();
33141

34142
{% endhighlight %}
35143

36144
{% endtabs %}
37145

38-
### Getting HTML Content Asynchronously
146+
### Move Cursor to End
39147

40-
To ensure you get the most up-to-date content, especially after recent edits, you can retrieve the HTML string asynchronously using the `GetHtmlString` method.
148+
Moves the cursor to the very end of the content in the editor.
41149

42150
{% tabs %}
43151

44152
{% highlight c# %}
45153

46-
string htmlContent = await rte.GetHtmlText();
154+
richTextEditor.MoveCursorToEnd();
47155

48156
{% endhighlight %}
49157

50158
{% endtabs %}
51159

160+
### Increase Indent
52161

53-
### Getting Selected HTML
162+
Increases the indentation of the current paragraph or selected paragraphs.
54163

55-
To retrieve the HTML representation of the currently selected content, use the `GetSelectedText` method.
164+
{% tabs %}
165+
166+
{% highlight c# %}
167+
168+
richTextEditor.IncreaseIndent();
169+
170+
{% endhighlight %}
171+
172+
{% endtabs %}
173+
174+
### Decrease Indent
175+
176+
Decreases the indentation of the current paragraph or selected paragraphs.
56177

57178
{% tabs %}
58179

59180
{% highlight c# %}
60181

61-
string selectedText = await rte.GetSelectedText();
182+
richTextEditor.DecreaseIndent();
62183

63184
{% endhighlight %}
64185

65186
{% endtabs %}
66187

67-
## Placeholder
188+
### Set Focus
68189

69-
The editor can display a placeholder text when the content is empty. This is useful for prompting the user. The placeholder is cleared as soon as the user starts typing.
190+
Programmatically sets the input focus to the rich text editor.
70191

71192
{% tabs %}
72193

73-
{% highlight xaml %}
194+
{% highlight c# %}
74195

75-
<rte:SfRichTextEditor Placeholder="Type Here..." />
196+
richTextEditor.Focus();
76197

77198
{% endhighlight %}
78199

200+
{% endtabs %}
201+
202+
### Remove Focus
203+
204+
Programmatically removes the input focus from the rich text editor.
205+
206+
{% tabs %}
207+
79208
{% highlight c# %}
80209

81-
SfRichTextEditor richTextEditor = new SfRichTextEditor();
82-
richTextEditor.Placeholder = "Type Here...";
210+
richTextEditor.Unfocus();
83211

84212
{% endhighlight %}
85213

86214
{% endtabs %}
87215

88-
![.NET MAUI Rich Text Editor with Placeholder](images/richtexteditor-placeholder.png)
216+
### Undo Last Action
217+
218+
Reverts the last action performed in the editor.
219+
220+
{% tabs %}
221+
222+
{% highlight c# %}
223+
224+
richTextEditor.Undo();
225+
226+
{% endhighlight %}
227+
228+
{% endtabs %}
229+
230+
### Redo Last Action
231+
232+
Re-applies the last action that was undone.
233+
234+
{% tabs %}
89235

90236

237+
{% highlight c# %}
238+
239+
richTextEditor.Redo();
240+
241+
{% endhighlight %}
242+
243+
{% endtabs %}
244+
91245
## Events
92246

93247
### FormatChanged Event

MAUI/Rich-Text-Editor/Customization.md

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ You can customize the visual style of the toolbar using the `Toolbar` property.
8282
<rte:RichTextEditorToolbarSettings BackgroundColor="LightSteelBlue"
8383
TextColor="DarkSlateGray" IsScrollButtonVisible="True"
8484
SeparatorColor="Brown" SeparatorThickness="5"
85-
ForwardIconBackground="Blue" ForwardIconColor="Green"
86-
BackwardIconBackground="Green" BackwardIconColor="Yellow"/>
85+
ForwardIconBackground="Blue" ForwardIconColor="Green"
86+
BackwardIconBackground="Green" BackwardIconColor="Yellow"/>
8787
</rte:SfRichTextEditor.ToolbarSettings>
8888
</rte:SfRichTextEditor>
8989

@@ -309,61 +309,3 @@ richTextEditor.RemoveHyperlink("Syncfusion", "https://www.google.com/");
309309
{% endtabs %}
310310

311311

312-
## Controlling Default Text Style
313-
314-
You can define the default appearance for any new text typed into the editor. These settings apply to text that does not have any other specific formatting applied.
315-
316-
* `DefaultFontFamily`: Sets the default font family for the content.
317-
* `DefaultFontSize`: Sets the default font size.
318-
* `DefaultTextColor`: Sets the default color of the text.
319-
320-
{% tabs %}
321-
{% highlight xaml %}
322-
323-
<rte:SfRichTextEditor DefaultFontFamily="Impact"
324-
DefaultFontSize="20"
325-
DefaultTextColor="DarkGreen" />
326-
327-
{% endhighlight %}
328-
{% highlight c# %}
329-
330-
SfRichTextEditor richTextEditor = new SfRichTextEditor();
331-
richTextEditor.DefaultFontFamily = "Impact";
332-
richTextEditor.DefaultFontSize = 20;
333-
richTextEditor.DefaultTextColor = Colors.DarkGreen;
334-
335-
{% endhighlight %}
336-
{% endtabs %}
337-
338-
## Customizing the Placeholder
339-
340-
The editor can display placeholder text when its content is empty. You can customize both the text and its appearance.
341-
342-
* `Placeholder`: Sets the text shown when the editor is empty.
343-
* `PlaceholderFontFamily`: Sets the font family of the placeholder text.
344-
* `PlaceholderFontSize`: Sets the font size of the placeholder text.
345-
* `PlaceholderColor`: Sets the color of the placeholder text.
346-
347-
{% tabs %}
348-
349-
{% highlight xaml %}
350-
351-
<rte:SfRichTextEditor Placeholder="Type your content here..."
352-
PlaceholderFontFamily="Impact"
353-
PlaceholderFontSize="36"
354-
PlaceholderColor="Green">
355-
</rte:SfRichTextEditor>
356-
357-
{% endhighlight %}
358-
359-
{% highlight c# %}
360-
361-
SfRichTextEditor richTextEditor = new SfRichTextEditor();
362-
richTextEditor.Placeholder = "Type your content here...";
363-
richTextEditor.PlaceholderFontFamily = "Impact";
364-
richTextEditor.PlaceholderFontSize = 16;
365-
richTextEditor.PlaceholderColor = Colors.Green;
366-
367-
{% endhighlight %}
368-
{% endtabs %}
369-

MAUI/Rich-Text-Editor/Image-Insertion.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ private async void OnImageInserting(object sender, RichTextEditorImageRequestedE
3232
e.IsHandled = true;
3333
RichTextEditorImageSource richTextEditorImageSource = new();
3434
richTextEditorImageSource.ImageFormat = RichTextEditorImageFormat.Base64;
35-
richTextEditorImageSource.Source = ImageSource.FromResource("dotnet_bot.png");
35+
richTextEditorImageSource.Source =ImageSource.FromUri(new Uri("https://aka.ms/campus.jpg"));
3636
richTextEditorImageSource.Width = 100;
3737
richTextEditorImageSource.Height = 20;
38-
(sender as SfRichTextEditor)?.InsertImage(richTextEditorImageSource);
38+
richTextEditor.InsertImage(richTextEditorImageSource);
3939
}
4040

4141
{% endhighlight %}
25.4 KB
Loading

0 commit comments

Comments
 (0)