Title: | Shiny Searchbar - An Input Widget for Highlighting Text and More |
---|---|
Description: | Add a searchbar widget to your 'Shiny' application. The widget quickly integrates with any existing element containing text to highlight matches. Highlighting is done with the 'JavaScript' library 'mark.js'. The widget includes buttons to cycle through multiple instances of the match and automatically scroll to the matches in an overflow element (or window). The widget also displays the total number of matches and which match is currently being cycled through. The widget is structured as a 'Bootstrap 3' input group. |
Authors: | Jesse Norris [aut, cre], Julian Kühnel [ctb] (mark.js) |
Maintainer: | Jesse Norris <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2024-11-04 03:33:15 UTC |
Source: | https://github.com/jes-n/shiny-searchbar |
All API options for mark.j v8.11.1, excluding the callback functions:
each
, filter
, noMatch
, and done
.
configurator
configurator
List with 15 named elements.
Element tag to wrap matches, default is "mark"
.
Class named appended to the match element,
default is ""
.
Vector of element selectors to exclude from match,
default is c()
.
Match algorithm ("partially"
, "complementary"
,
or "exactly"
), default is "partially"
.
(see mark.js API for more details).
List of key-value pairs to consider equivalent,
default is list()
.
Vector of punctuation marks to ignore,
default is c()
.
Matching using wildcards such as "?" and "*"
("disabled"
, "enabled"
, or "withSpaces"
), default is "disabled"
(see mark.js API for more details).
Search within iframe elements, default is FALSE
.
Maximum time (in ms) to wait for load before
skipping an iframe element, default is 5000
.
Search for each space-seperated word instead
of the complete input, default is TRUE
.
Match using diacritic characters, default is TRUE
.
Search for matches across elements,
default is FALSE
.
Case sensitive matching, default is FALSE
.
Skip soft hyphen, zero width space, zero width
non-joiner and zero width joiner, default is FALSE
.
Print debug information to the brower's console,
default is FALSE
.
See the mark.js API for a detailed description of each option. Also see the mark.js Configurator for these options in action.
Run one of the the shinySearchbar demos: "gallery" and "overflow".
demo(name = "gallery", ...)
demo(name = "gallery", ...)
name |
Name of the demo, either "gallery" or "overflow". |
... |
Remaining arguments are passed to |
if (interactive()) { shinySearchbar:::demo("gallery") }
if (interactive()) { shinySearchbar:::demo("gallery") }
Create a textInput-like searchbar which can search through and highlight the user's input within another element.
searchbar( inputId, contextId, value = NULL, label = NULL, width = NULL, placeholder = NULL, counter = TRUE, cycler = TRUE, scrollBehavior = c("smooth", "auto"), markOpts = configurator, quiet = FALSE )
searchbar( inputId, contextId, value = NULL, label = NULL, width = NULL, placeholder = NULL, counter = TRUE, cycler = TRUE, scrollBehavior = c("smooth", "auto"), markOpts = configurator, quiet = FALSE )
inputId |
The |
contextId |
The |
value |
Initial value. |
label |
Display label for the control, or |
width |
The width of the input, e.g. |
placeholder |
A character string giving the user a hint as to what can be entered into the control. Internet Explorer 8 and 9 do not support this option. |
counter |
Include a counter to display the number of matches found. |
cycler |
Include an interface to cycle between the matches. |
scrollBehavior |
Behavior of scrolling with |
markOpts |
Options to be passed to mark.js; see configurator and the mark.js API for more details. |
quiet |
Supress any warning related to incorrect/invalid arguments. |
The counter and cycler arguments add additional functionality to the searchbar. The counter shows the user how many matches were found and the cycler gives the user an interface to cycle through each match with automatic scrolling (using either the buttons or Enter and Shift+Enter).
The markOpts are a list of options to pass to the underlying mark.js API, which handles finding and highlighting the matches in element identified by contextId.
A seachbar input control that can be added to a UI definition.
updateMarkOptions, configurator
if (interactive()) { ui <- fluidPage( searchbar("sb", "text"), textOutput("text") ) server <- function(input, output) { output$text <- renderText("Hello world!") } shinyApp(ui, server) }
if (interactive()) { ui <- fluidPage( searchbar("sb", "text"), textOutput("text") ) server <- function(input, output) { output$text <- renderText("Hello world!") } shinyApp(ui, server) }
Only the options explicitly passed with this function are updated, the previous options are left unchanged.
updateMarkOptions( inputId, markOpts, session = shiny::getDefaultReactiveDomain(), quiet = FALSE )
updateMarkOptions( inputId, markOpts, session = shiny::getDefaultReactiveDomain(), quiet = FALSE )
inputId |
The |
markOpts |
Options to update for mark.js API. |
session |
The |
quiet |
Supress any warning related to incorrect/invalid arguments. |
No return value, called to update markOpts
of the input control.