Skip to content

Commit 353b607

Browse files
Merge pull request #451 from Syncfusion-Content/hotfix/hotfix-v26.1.35
DOCINFRA-2341_merged_using_automation
2 parents 014f93a + efaabe6 commit 353b607

File tree

1 file changed

+74
-2
lines changed

1 file changed

+74
-2
lines changed

ej2-react/document-editor/content-control.md

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ domainurl: ##DomainURL##
1010

1111
# Content control in React Document editor control
1212

13-
Document Editor provides content control preservation support (i.e.) Content control present in the input document is preserved upon saving.
13+
Document Editor provides support for inserting, editing content controls.
1414

1515
Content controls can be categorized based on its occurrence in a document as follows,
1616

@@ -26,4 +26,76 @@ BlockContentControl: Among paragraphs and tables, as a child of a Body, HeaderFo
2626
* Drop-Down List and Combo Box
2727
* Picture
2828

29-
>Note: Content control with custom XML mapping of file type WordML is converted as normal Rich Text Content Control to provide lossless round-tripping upon saving.
29+
## Insert content control
30+
31+
Content control can be inserted using [`insertContentControl`](https://ej2.syncfusion.com/react/documentation/api/document-editor/editor/#insertcontentcontrol) method in editor module.
32+
33+
{% highlight ts %}
34+
//Insert Rich Text Content Control
35+
this.container.documentEditor.editor.insertContentControl('RichText');
36+
//Insert Rich Text Content Control with default sfdt string
37+
let sfdt = {"sections":[{"blocks":[{"inlines":[{"text": "Hello"}]}]}]};
38+
this.container.documentEditor.editor.insertContentControl('RichText', sfdt);
39+
40+
//Insert Plain Text Content Control
41+
this.container.documentEditor.editor.insertContentControl('Text');
42+
//Insert Plain Text Content Control with default string
43+
this.container.documentEditor.editor.insertContentControl('Text', 'Hello World');
44+
45+
//Insert CheckBox Content Control
46+
this.container.documentEditor.editor.insertContentControl('CheckBox');
47+
//Insert CheckBox Content Control with mention checked state
48+
this.container.documentEditor.editor.insertContentControl('CheckBox', true);
49+
50+
//Insert ComboBox Content Control
51+
this.container.documentEditor.editor.insertContentControl('ComboBox');
52+
//Insert ComboBox Content Control with items
53+
this.container.documentEditor.editor.insertContentControl('ComboBox', 'One', ['One', 'Two', 'Three']);
54+
55+
//Insert Date Content Control
56+
this.container.documentEditor.editor.insertContentControl('Date');
57+
//Insert Date Content Control
58+
this.container.documentEditor.editor.insertContentControl('Date', '01/01/2024');
59+
60+
//Insert DropDownList Content Control
61+
this.container.documentEditor.editor.insertContentControl('DropDownList');
62+
//Insert DropDownList Content Control with items
63+
this.container.documentEditor.editor.insertContentControl('DropDownList', 'One', ['One', 'Two', 'Three']);
64+
65+
//Insert Picture Content Control
66+
this.container.documentEditor.editor.insertContentControl('Picture');
67+
//Insert Picture Content Control with default image
68+
this.container.documentEditor.editor.insertContentControl('Picture', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADgSURBVEhLY3jx4sV/WuDBafCluXH/D6ydhlWObIMPLmn8/32KPBiD2OjyKAY7+zbDsX945/91azehiBWU9IPVgVwJMxSX4SgG65jXwrGVa+v/6TOXoojBDEZ2LQh/m676/+D+/XBzQJgsg0EY5GqQgSCDsYUz2QaDMCiosIUvCKMYDFKIjK9dvYrCB3kXJIaMkfUjY5JdDEpioCCAYZCFyGbAMFkGI0fcMDUYpAgZY4s8EEYWwxWBJLsYhJHFQIYjmwHDQ9xgkGEwDCp0QAYji8EMRhYjymBq4lGDofjFfwCV5AGEIf9DQQAAAABJRU5ErkJggg==');
69+
{% endhighlight %}
70+
71+
## Import content control properties
72+
73+
Content control properties can be set using the [`ContentControlInfo`](https://ej2.syncfusion.com/react/documentation/api/document-editor/contentControlInfo/) and import it using [`importContentControlData`](https://ej2.syncfusion.com/react/documentation/api/document-editor/#importcontentcontroldata)
74+
75+
{% highlight ts %}
76+
let data: ContentControlInfo[] = [];
77+
let contentControlData: ContentControlInfo = { title: placeHolderPrefix + 'Name', tag: '', value: 'John', canDelete: false, canEdit: false, type: 'RichText' };
78+
data.push(contentControlData);
79+
this.container.documentEditor.importContentControlData(data);
80+
{% endhighlight %}
81+
82+
## Export content control properties
83+
84+
Content control properties can be exported using the [`exportContentControlData`](https://ej2.syncfusion.com/react/documentation/api/document-editor/#exportcontentcontroldata)
85+
86+
{% highlight ts %}
87+
let contentControlInfos: ContentControlInfo[] = this.container.documentEditor.exportContentControlData();
88+
{% endhighlight %}
89+
90+
## Reset content control
91+
92+
Content control properties can be reset using the [`resetcontentcontroldata`](https://ej2.syncfusion.com/react/documentation/api/document-editor/#resetcontentcontroldata)
93+
94+
{% highlight ts %}
95+
let data: ContentControlInfo[] = [];
96+
let contentControlData: ContentControlInfo = { title: placeHolderPrefix + 'Name', tag: '', value: 'John', canDelete: false, canEdit: false, type: 'RichText' };
97+
data.push(contentControlData);
98+
this.container.documentEditor.resetContentControlData(data);
99+
{% endhighlight %}
100+
101+
>Note: Content control with custom XML mapping of file type WordML is converted as normal Rich Text Content Control to provide lossless round-tripping upon saving.

0 commit comments

Comments
 (0)