@@ -83,6 +83,107 @@ Where:
8383
8484` allowedTags ` param should follow [ HTMLPurifier] ( https://github.com/ezyang/htmlpurifier] ) format.
8585
86+ #### There are three common parameters for every block:
87+
88+ 1 . ` type ` (** required** ) — type of the block
89+
90+ | value| description|
91+ | ---| ---|
92+ | ` string ` | field with string value|
93+ | ` int ` /` integer ` | field with integer value|
94+ | ` bool ` /` boolean ` | field with boolean value|
95+ | ` array ` | field with nested fields|
96+
97+ 2 . ` allowedTags ` (optional) — HTML tags in string that won't be removed
98+
99+ | value| default| description|
100+ | ---| ---| ---|
101+ | ` empty ` | yes| all tags will be removed|
102+ | ` * ` | no| all tags are allowed|
103+
104+ Other values are allowed according to the [ HTMLPurifier] ( https://github.com/ezyang/htmlpurifier] ) format.
105+
106+ Example:
107+ ```
108+ "paragraph": {
109+ "text": {
110+ "type": "string",
111+ "allowedTags": "i,b,u,a[href]"
112+ }
113+ }
114+ ```
115+
116+ 3 . ` canBeOnly ` (optional) — define set of allowed values
117+ Example:
118+ ```
119+ "quote": {
120+ "text": {
121+ "type": "string"
122+ },
123+ "caption": {
124+ "type": "string"
125+ },
126+ "alignment": {
127+ "type": "string",
128+ "canBeOnly": ["left", "center"]
129+ }
130+ }
131+ ```
132+
133+ #### Nested tools
134+
135+ Tools can contain nested values. It is possible with the ` array ` type.
136+
137+ Let the JSON input be the following:
138+ ```
139+ {
140+ "blocks": [
141+ "type": list,
142+ "data": {
143+ "items": [
144+ "first", "second", "third"
145+ ],
146+ "style": {
147+ "background-color": "red",
148+ "font-color": "black"
149+ }
150+ }
151+ ]
152+ }
153+ ```
154+
155+ We can define validation rules for this input in the config:
156+ ```
157+ "list": {
158+ "items": {
159+ "type": "array",
160+ "data": {
161+ "-": {
162+ "type": "string",
163+ "allowedTags": "i,b,u"
164+ }
165+ }
166+ },
167+ "style": {
168+ "type": "array",
169+ "data": {
170+ "background-color": {
171+ "type": "string",
172+ "canBeOnly": ["red", "blue", "green"]
173+ },
174+ "font-color": {
175+ "type": "string",
176+ "canBeOnly": ["black", "white"]
177+ }
178+ }
179+ }
180+ }
181+ ```
182+
183+ where ` data ` is the container for values of the array and ` - ` is the special shortcut for values if the array is sequential.
184+
185+
186+
86187Another configuration example: [ /tests/samples/test-config.json] ( /tests/samples/test-config.json )
87188
88189# Exceptions
0 commit comments