@@ -10,7 +10,6 @@ import {
10
10
import { DEFAULT_INDEX } from "../../packages/textcomplete-core/src/Strategy"
11
11
12
12
import { Code } from "../components/Code"
13
- import { Section } from "../components/Section"
14
13
15
14
interface Props {
16
15
id : string
@@ -127,7 +126,8 @@ const SAMPLE_OPTION = `
127
126
`
128
127
129
128
export const Usage : FC < Props > = ( { id } ) => (
130
- < Section id = { id } title = "Usage" >
129
+ < section >
130
+ < h1 id = { id } > Usage</ h1 >
131
131
< Code code = "npm install --save @textcomplete/core" language = "bash" />
132
132
< p >
133
133
You also need to install an < a href = "#editors" > editor</ a > package. An
@@ -139,117 +139,126 @@ export const Usage: FC<Props> = ({ id }) => (
139
139
with an editor:
140
140
</ p >
141
141
< Code code = { INITIALIZE_CODE } language = "javascript" />
142
- < h3 > How it works</ h3 >
143
- < ol >
144
- < li > (An input event is triggered to the underlying HTML element.)</ li >
145
- < li >
146
- The < code > editor</ code > emits a change event.
147
- </ li >
148
- < li >
149
- For each registered strategy:
150
- < ol >
151
- < li > [Context phase] Test context (Optional).</ li >
152
- < li >
153
- [Match phase] Try extracting a search term. If it fails, continue to
154
- the next strategy.
155
- </ li >
156
- < li >
157
- [Search phase] Gather candidates using the search term. The way how
158
- to gather them is completely up to you.
159
- </ li >
160
- < li > [Render phase] Show a dropdown UI rendering the candidates.</ li >
161
- </ ol >
162
- </ li >
163
- < li >
164
- When user selects a dropdown item by either clicking it or pushing an
165
- enter key, the < code > editor</ code > 's value is updated.
166
- </ li >
167
- </ ol >
168
- < h3 id = "strategy" > Strategy</ h3 >
169
- < p >
170
- A < code > strategy</ code > object represents a rule of autocompletion. The{ " " }
171
- < code > match</ code > , < code > search</ code > and < code > replace</ code > keys are
172
- required.
173
- </ p >
174
- < Code code = { SAMPLE_STRATEGY } language = "typescript" />
175
- < h3 id = "strategy" > Option</ h3 >
176
- < p >
177
- An < code > option</ code > object affects rest of behavior.
178
- </ p >
179
- < Code code = { SAMPLE_OPTION } language = "typescript" />
180
- < h3 id = "events" > Events</ h3 >
181
- < p >
182
- Textcomplete provides custom events for most actions. Generally, these
183
- come in an infinitive and past participle form - where the infinitive (ex.{ " " }
184
- < code > show</ code > ) is triggered at the start of an event, and its past
185
- participle form (ex. < code > shown</ code > ) is triggered on the completion of
186
- an action.
187
- </ p >
188
- < p >
189
- An infinitive events provide < code > preventDefault</ code > functionality.
190
- This provides the ability to stop the execution of an action before it
191
- starts.
192
- </ p >
193
- < table >
194
- < thead >
195
- < tr >
196
- < th style = { { minWidth : "100px" } } > Event Type</ th >
197
- < th > Description</ th >
198
- </ tr >
199
- </ thead >
200
- < tbody >
201
- < tr >
202
- < td > show</ td >
203
- < td > Fired immediately when the dropdown is going to be shown.</ td >
204
- </ tr >
205
- < tr >
206
- < td > shown</ td >
207
- < td >
208
- Fired when the dropdown has been made visible to the user (will wait
209
- for CSS transitions to complete).
210
- </ td >
211
- </ tr >
212
- < tr >
213
- < td > render</ td >
214
- < td >
215
- Fired immediately when dropdown items are goint to be visible to the
216
- user.
217
- </ td >
218
- </ tr >
219
- < tr >
220
- < td > rendered</ td >
221
- < td >
222
- Fired when the dropdown items have been visible to the user (will
223
- wait for CSS transitions to complete).
224
- </ td >
225
- </ tr >
226
- < tr >
227
- < td > select</ td >
228
- < td > Fired immediately when a dropdown item is selected.</ td >
229
- </ tr >
230
- < tr >
231
- < td > selected</ td >
232
- < td >
233
- Fired when the selected dropdown item was applied to the editor
234
- (will wait for CSS transitions to complete).
235
- </ td >
236
- </ tr >
237
- < tr >
238
- < td > hide</ td >
239
- < td > Fired immediately when the dropdown is going to be hidden.</ td >
240
- </ tr >
241
- < tr >
242
- < td > hidden</ td >
243
- < td >
244
- Fired when the dropdown has finished being hidden from the user
245
- (will wait for CSS transitions to complete).
246
- </ td >
247
- </ tr >
248
- </ tbody >
249
- </ table >
250
- < p >
251
- The native < code > input</ code > event is dispatched to the textarea element
252
- when its value is changed because a search result has been selected.
253
- </ p >
254
- </ Section >
142
+ < section >
143
+ < h2 > How it works</ h2 >
144
+ < ol >
145
+ < li > (An input event is triggered to the underlying HTML element.)</ li >
146
+ < li >
147
+ The < code > editor</ code > emits a change event.
148
+ </ li >
149
+ < li >
150
+ For each registered strategy:
151
+ < ol >
152
+ < li > [Context phase] Test context (Optional).</ li >
153
+ < li >
154
+ [Match phase] Try extracting a search term. If it fails, continue
155
+ to the next strategy.
156
+ </ li >
157
+ < li >
158
+ [Search phase] Gather candidates using the search term. The way
159
+ how to gather them is completely up to you.
160
+ </ li >
161
+ < li > [Render phase] Show a dropdown UI rendering the candidates.</ li >
162
+ </ ol >
163
+ </ li >
164
+ < li >
165
+ When user selects a dropdown item by either clicking it or pushing an
166
+ enter key, the < code > editor</ code > 's value is updated.
167
+ </ li >
168
+ </ ol >
169
+ </ section >
170
+ < section >
171
+ < h2 id = "strategy" > Strategy</ h2 >
172
+ < p >
173
+ A < code > strategy</ code > object represents a rule of autocompletion. The{ " " }
174
+ < code > match</ code > , < code > search</ code > and < code > replace</ code > keys
175
+ are required.
176
+ </ p >
177
+ < Code code = { SAMPLE_STRATEGY } language = "typescript" />
178
+ </ section >
179
+ < section >
180
+ < h2 id = "strategy" > Option</ h2 >
181
+ < p >
182
+ An < code > option</ code > object affects rest of behavior.
183
+ </ p >
184
+ < Code code = { SAMPLE_OPTION } language = "typescript" />
185
+ </ section >
186
+ < section >
187
+ < h2 id = "events" > Events</ h2 >
188
+ < p >
189
+ Textcomplete provides custom events for most actions. Generally, these
190
+ come in an infinitive and past participle form - where the infinitive
191
+ (ex. < code > show</ code > ) is triggered at the start of an event, and its
192
+ past participle form (ex. < code > shown</ code > ) is triggered on the
193
+ completion of an action.
194
+ </ p >
195
+ < p >
196
+ An infinitive events provide < code > preventDefault</ code > functionality.
197
+ This provides the ability to stop the execution of an action before it
198
+ starts.
199
+ </ p >
200
+ < table >
201
+ < thead >
202
+ < tr >
203
+ < th style = { { minWidth : "100px" } } > Event Type</ th >
204
+ < th > Description</ th >
205
+ </ tr >
206
+ </ thead >
207
+ < tbody >
208
+ < tr >
209
+ < td > show</ td >
210
+ < td > Fired immediately when the dropdown is going to be shown.</ td >
211
+ </ tr >
212
+ < tr >
213
+ < td > shown</ td >
214
+ < td >
215
+ Fired when the dropdown has been made visible to the user (will
216
+ wait for CSS transitions to complete).
217
+ </ td >
218
+ </ tr >
219
+ < tr >
220
+ < td > render</ td >
221
+ < td >
222
+ Fired immediately when dropdown items are goint to be visible to
223
+ the user.
224
+ </ td >
225
+ </ tr >
226
+ < tr >
227
+ < td > rendered</ td >
228
+ < td >
229
+ Fired when the dropdown items have been visible to the user (will
230
+ wait for CSS transitions to complete).
231
+ </ td >
232
+ </ tr >
233
+ < tr >
234
+ < td > select</ td >
235
+ < td > Fired immediately when a dropdown item is selected.</ td >
236
+ </ tr >
237
+ < tr >
238
+ < td > selected</ td >
239
+ < td >
240
+ Fired when the selected dropdown item was applied to the editor
241
+ (will wait for CSS transitions to complete).
242
+ </ td >
243
+ </ tr >
244
+ < tr >
245
+ < td > hide</ td >
246
+ < td > Fired immediately when the dropdown is going to be hidden.</ td >
247
+ </ tr >
248
+ < tr >
249
+ < td > hidden</ td >
250
+ < td >
251
+ Fired when the dropdown has finished being hidden from the user
252
+ (will wait for CSS transitions to complete).
253
+ </ td >
254
+ </ tr >
255
+ </ tbody >
256
+ </ table >
257
+ < p >
258
+ The native < code > input</ code > event is dispatched to the textarea
259
+ element when its value is changed because a search result has been
260
+ selected.
261
+ </ p >
262
+ </ section >
263
+ </ section >
255
264
)
0 commit comments