-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor shinyAce #62
Conversation
-> Rather than building a script and inserting it in the HTML body every time an editor is created, we move the element creation logic in the "initialize" step of the shiny widget. -> [R] functions (aceEditor, updateAceEditor) create a JSON payload only that is attached to the appropriate element. -> Shared Javascript code-path for widget initialization, and widget update (shinyAce.js: updateEditor). -> Make JS <-> server.R communication fully module friendly (selectionId, cursorId, hotkeys). These are all now reported with a prefix "inputId_" (similar to shinyAce_hint). This is a breaking change. -> Add couple of examples.
I am open to this although I am a bit concerned about breaking changes. Would you be willing to help out with (new) issues that might pop-up due to the proposed changes? I mainly use cc-ing @saurfang |
Thanks for giving this a look, and I can appreciate the hesitation to break existing code. Let me know if you have any ideas on how it can be avoided. Happy to help out with problems as they arise in the future, time permitting. Apologies for the |
Thanks @detule. The JS error is now gone, however, auto-complete and line selection no longer work. Can you give some more information about what changes are likely needed in existing code? |
As far as line selection, I suspect it's a matter of observing For |
@detule I double checked but the id I have been using for the selection was already in the format you suggested (see link below). The autocomplete examples in shinyAce do work but, for some, break autocompletion are now broken in radiant.data (Report > Rmd and Report > R) |
Thanks again for your patience here.
|
@detule I figured out what was going on in my app. Before merging I'd like to check with two recent contributors (cc-ed) to get their input and thoughts. |
@vnijs: Thanks for cc-ing. I am running into problems with remotes::install_github("trestletech/shinyAce", ref = "690491e") but not with remotes::install_github("detule/shinyAce", ref = "7ab2d2c") The
App library(shiny)
editorModuleUI <- function(id) {
ns <- NS(id)
shinyAce::aceEditor(
ns("editor"),
mode = "r",
autoComplete = "live"
)
}
editorModuleServer <- function(input, output, session) {
shinyAce::aceAutocomplete("editor")
}
shinyApp(
ui = fluidPage(
editorModuleUI("myEditor")
),
server = function(input, output, session) {
callModule(editorModuleServer, "myEditor")
}
) Shiny version (newest CRAN) sessioninfo::package_info(pkgs = "shiny", dependencies = FALSE)
#> package * version date lib source
#> shiny * 1.3.2 2019-04-22 [2] CRAN (R 3.6.0) The version above, where
See also #49 for the steps that were undertaken to make |
Thanks @GregorDeCillia - appreciate the minimal example. Nice work with making the |
You are very welcome @detule. I just updated to the top of |
Thanks @GregorDeCillia. I will assume this means you are ok with the refactor by @detule. @detule Can you add a few lines at the top of the README.md file so indicate that (1) shinyAce 0.4.0 has breaking changes and (2) what those changes are and how to address them in existing code? Once we have that I will add @detule as a contributor and submit to CRAN unless @saurfang sees any remaining issues |
@vnijs shouldn't the breaking changes be noted in NEWS.md rather than README.md? I'll do some quick checks tomorrow on a bigger project of mine that uses submodules and automatically generated IDs and report back. But I'm pretty sure there will be no issues. |
@GregorDeCillia Yes. We will also list the breaking changes in NEWS.md. However, README.md is a form of (limited) documentation. It should include the new examples as well and all examples should be updated to reflect the breaking changes (e.g., Each listed example could then mention something like: "Note: As of shinyAce version 0.4.0 ..." I also think we should also use something like the following to start the examples so the user sees the apps in display mode. shiny::runApp(system.file("examples/06-autocomplete", package="shinyAce"), display.mode = "showcase"); |
I'd like to add a https://stackoverflow.com/questions/26695708/how-can-i-add-placeholder-text-when-the-editor-is-empty if (data.hasOwnProperty('placeholder')) {
function update() {
var shouldShow = !editor.session.getValue().length;
var node = editor.renderer.emptyMessageNode;
if (!shouldShow && node) {
editor.renderer.scroller.removeChild(editor.renderer.emptyMessageNode);
editor.renderer.emptyMessageNode = null;
} else if (shouldShow && !node) {
node = editor.renderer.emptyMessageNode = document.createElement("div");
node.textContent = data.placeholder;
node.className = "ace_invisible ace_emptyMessage";
node.style.padding = "0 5px";
editor.renderer.scroller.appendChild(node);
}
}
editor.on("input", update);
setTimeout(update, 100);
} |
I just tested the newest version of |
I'm going to merge this PR and do some work on documentation. Thanks @detule! |
@detule I just pushed some work updating the examples and the README.md. However, I noticed that since the latest update you made, autocomplete in example 6 no longer seems to work. Can you take a look? |
@detule FYI I found the problem and pushed a fix |
Hello!
First of all let me apologize for the breadth of the single commit in this PR - if you find value in it, I am happy to work with you on breaking it up into more maneagable pieces.
My use case is a dashboard that makes extensive use of modules, and with multiple editors embedded in the page. I was struggling with:
To alleviate this, I (below taken from the commit message):
Thanks!