You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This section covers the essential properties, methods, and events of the .NET MAUI `SfRichTextEditor` for handling content and user interactions.
13
13
14
-
## Handling Content
14
+
## Setting Text
15
15
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.
17
17
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 <b> rich text editor </b> 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.
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();

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.
19
100
20
101
{% tabs %}
21
102
22
103
{% highlight xaml %}
23
104
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>
25
110
26
111
{% endhighlight %}
27
112
28
113
{% highlight c# %}
29
114
30
115
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
+

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();
33
141
34
142
{% endhighlight %}
35
143
36
144
{% endtabs %}
37
145
38
-
### Getting HTML Content Asynchronously
146
+
### Move Cursor to End
39
147
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.
41
149
42
150
{% tabs %}
43
151
44
152
{% highlight c# %}
45
153
46
-
string htmlContent = await rte.GetHtmlText();
154
+
richTextEditor.MoveCursorToEnd();
47
155
48
156
{% endhighlight %}
49
157
50
158
{% endtabs %}
51
159
160
+
### Increase Indent
52
161
53
-
### Getting Selected HTML
162
+
Increases the indentation of the current paragraph or selected paragraphs.
54
163
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.
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.
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();
0 commit comments