mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4152] Updated folder structure of core docs (#4415)
* [ADF-4152] Moved core library docs into subfolders * [ADF-4152] Moved core library docs into subfolders * [ADF-4152] Manual fixes to core doc file links * [ADF-4152] Further automatic + manual link tidying
This commit is contained in:
committed by
Eugenio Romano
parent
285e56e9fb
commit
5fc05da7aa
52
docs/core/services/highlight-transform.service.md
Normal file
52
docs/core/services/highlight-transform.service.md
Normal file
@@ -0,0 +1,52 @@
|
||||
---
|
||||
Title: Highlight Transform service
|
||||
Added: v2.0.0
|
||||
Status: Active
|
||||
Last reviewed: 2018-11-13
|
||||
---
|
||||
|
||||
# [Highlight Transform service](../../../lib/core/services/highlight-transform.service.ts "Defined in highlight-transform.service.ts")
|
||||
|
||||
Adds HTML to a string to highlight chosen sections.
|
||||
|
||||
## Class members
|
||||
|
||||
### Methods
|
||||
|
||||
- **highlight**(text: `string`, search: `string`, wrapperClass: `string` = `"adf-highlight"`): [`HighlightTransformResult`](../../../lib/core/services/highlight-transform.service.ts)<br/>
|
||||
Searches for `search` string(s) within `text` and highlights all occurrences.
|
||||
- _text:_ `string` - Text to search within
|
||||
- _search:_ `string` - Text pattern to search for
|
||||
- _wrapperClass:_ `string` - CSS class used to provide highlighting style
|
||||
- **Returns** [`HighlightTransformResult`](../../../lib/core/services/highlight-transform.service.ts) - New text along with boolean value to indicate whether anything was highlighted
|
||||
|
||||
## Details
|
||||
|
||||
A typical use case for this service is to display the results from a search engine.
|
||||
An excerpt of a retrieved document can be shown with the matching search terms
|
||||
highlighted to indicate where they were found.
|
||||
|
||||
The service works by adding HTML <span> elements around all sections of text
|
||||
that match the `search` string. You can specify multiple search strings at once by
|
||||
separating them with spaces, so passing "Apple Banana Cherry" in `search` will
|
||||
highlight any of those words individually. The <span> element includes a
|
||||
`class` attribute which defaults to "highlight" but you can pass any class name
|
||||
you like using the `wrapperClass` parameter.
|
||||
|
||||
The resulting text with HTML highlighting is returned within a [`HighlightTransformResult`](../../../lib/core/services/highlight-transform.service.ts)
|
||||
object:
|
||||
|
||||
```ts
|
||||
interface HighlightTransformResult {
|
||||
text: string;
|
||||
changed: boolean;
|
||||
}
|
||||
```
|
||||
|
||||
The `changed` flag will be false if the search string was not found (ie, no highlighting
|
||||
took place) and true otherwise.
|
||||
|
||||
## See also
|
||||
|
||||
- [Text highlight pipe](../pipes/text-highlight.pipe.md)
|
||||
- [Highlight directive](../directives/highlight.directive.md)
|
Reference in New Issue
Block a user