Ace editor bindings to enable a rich text editing environment within Shiny.
shinyAce package enables Shiny application developers to use the
Ace text editor in their applications. All
current modes (languages) and themes are supported in this package. The
mode, theme, and current text can be defined when the element is initialized
ui.R or afterwards using the
updateAceEditor() function. The editor
registers itself as a reactive Shiny input, so the current value of the
editor can easily be pulled from
Or view an interactive example.
shinyAce is available on CRAN, so installation is as simple as:
You can install the latest development version of the code using the
devtools R package.
install.packages("devtools") library(devtools) install_github("trestletech/shinyAce")
Various examples are available in the
inst/examples directory included in the package. A few examples are described below. (Note that the package must be installed before you can run any examples.)
library(shiny); runApp(system.file("examples/01-basic", package="shinyAce"));
Demonstrates the basic capabilities of shinyAce including the ability to set an initial value, or interactively assign a value, theme, or mode later on in the session.
library(shiny); runApp(system.file("examples/02-eval", package="shinyAce"));
Shows an example of using shinyAce to allow the user to compose R code which will then be evaluated on the server.
library(shiny); runApp(system.file("examples/03-knitr", package="shinyAce"));
library(shiny); runApp(system.file("examples/04-shinyui", package="shinyAce"));
Demonstrates using shinyAce to allow a user to create a Shiny UI within Shiny itself. The UI can then be rendered on the right half of the page. Could be a great learning tool for teaching how to construct Shiny UIs.
library(shiny); runApp(system.file("examples/05-hotkeys", package="shinyAce"));
An example using the
hotkeys feature of ShinyAce to allow application developers to expose keyboard shortcuts to their users.
library(shiny); runApp(system.file("examples/06-autocomplete", package="shinyAce"));
An example using the
autocomplete feature of ShinyAce to enable Ace to suggest completions as the user types.
As with any online application, it is a genuinely bad idea to allow arbitrary users to execute code on your server. The above examples show such an environment in which arbitrary R code is being executed on a remote machine. In a trusted environment (such as after authenticating a user or on a network protected by a firewall), this may not be a terrible idea; on a public server without authentication, it most certainly is. So please use the above examples with caution, realizing that without proper security checks in place, allowing unknown users to execute arbitrary R code would make it trivial for an attacker to compromise your server or steal your private data.
See the Issues page for information on outstanding issues.
The development of this project was generously sponsored by the Institut de Radioprotection et de Sûreté Nucléaire and performed by Jeff Allen. The code is licensed under The MIT License (MIT).
Copyright (c) 2013 Institut de Radioprotection et de Sûreté Nucléaire
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
selectionIdin the call to
Keyboard shortcuts for to execute code blocks, code chunks, and equations in display form using CTRL-enter (CMD-enter on macOS)
Added options to set tab size (tabSize), replace tabs by spaces (useSoftTabs), and show invisible characters (showInvisibles). See
Upgrade to Ace 1.3.0 (https://github.com/ajaxorg/ace-builds/releases)
Allow toggling of search-replace using CMD-f (CTRL-f on Windows). See https://github.com/ajaxorg/ace/issues/3552)
Clear editor using "" (@dmenne #30)
Fix when ace is initialized with \r or \f (@The-Dub #46)
Fix for auto complete in shiny modules (@GregorDeCillia #47 and PR54)
Note: This fix required a breaking change (i.e., the
aceAutocomplete function now uses
inputid_shinAce_hint rather than the the old
Fix for auto complete lists (@Ping2016 #48 and @saurfang (PR52)
Improved configuration options for auto completers by @saurfang ([PR53]https://github.com/trestletech/shinyAce/pull/53))
Upgrade to Ace 1.1.8
Add code autocompletion (@saurfang, #21)
Added input debouncing
Add shortcut and cursor listeners (@skranz, #16)
Added word wrapping (@ncarchedi, #12)
Added vim key bindings (@Vincent, #9)