Skip to content

Commit 6714e1b

Browse files
committed
added editor_proxy_reset()
1 parent c375fbe commit 6714e1b

File tree

12 files changed

+190
-35
lines changed

12 files changed

+190
-35
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: toastui
2-
Title: Interactive Tables, Calendars and Charts for the Web
3-
Version: 0.4.0
2+
Title: Interactive Tables, Calendars, Charts and Editor for the Web
3+
Version: 0.4.0.9000
44
Authors@R: c(
55
person("Victor", "Perrier", email = "victor.perrier@dreamrs.fr", role = c("aut", "cre", "cph")),
66
person("Fanny", "Meyer", role = "aut"),

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export(editor_proxy)
4242
export(editor_proxy_change_preview)
4343
export(editor_proxy_hide)
4444
export(editor_proxy_insert)
45+
export(editor_proxy_reset)
4546
export(editor_proxy_show)
4647
export(grid_click)
4748
export(grid_col_button)

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# toastui 0.4.1
2+
3+
* Added proxy method `editor_proxy_reset()` to reset an editor.
4+
5+
16
# toastui 0.4.0
27

38
* New htmlwidget `editor()`, a Markdown WYSIWYG Editor (https://ui.toast.com/tui-editor).

R/editor-proxy.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,26 @@ editor_proxy_insert <- function(proxy, text) {
9494
)
9595
}
9696

97+
#' Reset an editor
98+
#'
99+
#' @param proxy A [editor_proxy()] or `outputId` of the editor
100+
#'
101+
#' @return A `editor_proxy` object.
102+
#' @export
103+
#'
104+
#' @family editor proxy methods
105+
#'
106+
#' @example examples/editor-proxy.R
107+
editor_proxy_reset <- function(proxy) {
108+
if (is.character(proxy)) {
109+
proxy <- editor_proxy(proxy)
110+
}
111+
.call_proxy(
112+
proxy = proxy,
113+
name = "editor-reset"
114+
)
115+
}
116+
97117

98118
#' @title Show/hide an editor
99119
#'

examples/editor-proxy.R

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ ui <- fluidPage(
1414
),
1515
checkboxInput(
1616
inputId = "showhide",
17-
label = "Show/hide editor",
17+
label = "Show/hide editor",
1818
value = TRUE
1919
),
2020
textInput(
2121
inputId = "text",
2222
label = "Text to insert:",
2323
width = "100%"
2424
),
25-
actionButton("insert", "Insert text")
25+
actionButton("insert", "Insert text", width = "100%"),
26+
tags$br(), tags$br(),
27+
actionButton("reset", "Reset", width = "100%")
2628
),
2729
column(
2830
width = 8,
@@ -32,27 +34,31 @@ ui <- fluidPage(
3234
)
3335

3436
server <- function(input, output, session) {
35-
37+
3638
output$my_editor <- renderEditor({
3739
editor()
3840
})
39-
41+
4042
observeEvent(input$changePreviewStyle, {
4143
editor_proxy_change_preview("my_editor", input$changePreviewStyle)
4244
}, ignoreInit = TRUE)
43-
45+
4446
observeEvent(input$showhide, {
4547
if (input$showhide) {
4648
editor_proxy_show("my_editor")
4749
} else {
4850
editor_proxy_hide("my_editor")
4951
}
5052
}, ignoreInit = TRUE)
51-
53+
5254
observeEvent(input$insert, {
5355
editor_proxy_insert("my_editor", text = input$text)
5456
})
55-
57+
58+
observeEvent(input$reset, {
59+
editor_proxy_reset("my_editor")
60+
})
61+
5662
}
5763

5864
if (interactive())

inst/htmlwidgets/editor.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/editor-proxy-show-hide.Rd

Lines changed: 15 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/editor_proxy.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/editor_proxy_change_preview.Rd

Lines changed: 15 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/editor_proxy_insert.Rd

Lines changed: 15 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)