From 8c707f197424c2021b7a8772fe485a34dcf7ce67 Mon Sep 17 00:00:00 2001 From: Stathis Date: Thu, 4 Apr 2024 20:22:12 -0700 Subject: [PATCH 1/7] Allow setting Monaco editor `quickSuggestions` option using quarto `editor-quick-suggestions` option, defaulting to `true` --- _extensions/webr/qwebr-monaco-editor-element.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_extensions/webr/qwebr-monaco-editor-element.js b/_extensions/webr/qwebr-monaco-editor-element.js index 19168693..fa372b86 100644 --- a/_extensions/webr/qwebr-monaco-editor-element.js +++ b/_extensions/webr/qwebr-monaco-editor-element.js @@ -29,7 +29,8 @@ globalThis.qwebrCreateMonacoEditorInstance = function (cellData) { fontSize: '17.5pt', // Bootstrap is 1 rem renderLineHighlight: "none", // Disable current line highlighting hideCursorInOverviewRuler: true, // Remove cursor indictor in right hand side scroll bar - readOnly: qwebrOptions['read-only'] ?? false + readOnly: qwebrOptions['read-only'] ?? false, + quickSuggestions: qwebrOptions['editor-quick-suggestions'] ?? true }); // Store the official counter ID to be used in keyboard shortcuts From 1fdcf4650ac06b29c4a1428d5871bffb58f21198 Mon Sep 17 00:00:00 2001 From: James J Balamuta Date: Thu, 4 Apr 2024 21:09:52 -0700 Subject: [PATCH 2/7] Add `editor-quick-suggestions` key to cell options and split the documentation --- docs/qwebr-cell-options.qmd | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/docs/qwebr-cell-options.qmd b/docs/qwebr-cell-options.qmd index c27cbb17..344d28ed 100644 --- a/docs/qwebr-cell-options.qmd +++ b/docs/qwebr-cell-options.qmd @@ -33,18 +33,34 @@ The `{quarto-webr}` extension does not support all of the cell options from [Qua ## quarto-webr -| Option | Default Value | Description | -|-------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `context` | `interactive` | Describe how the cell should operate on the page through either `interactive` (Runnable code editor), `output` (Output only of executed at runtime), or `setup` (execute code without seeing output at runtime). | -| `autorun` | `false` | Allow `interactive` cells to be run during document initialization without a user pressing run code. | -| `read-only` | `false` | Prevent code in `interactive` cells from being modified by disallowing code input. | -| `editor-max-height` | `0` | Set a threshold to prevent infinite growth of the editor window. | +:::{.callout-note} +Options listed here are unique to the `{quarto-webr}` extension and do not have a Quarto equivalent. +::: + +### Run Options + +| Option | Default Value | Description | +|----------------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `context` | `interactive` | Describe how the cell should operate on the page through either `interactive` (Runnable code editor), `output` (Output only of executed at runtime), or `setup` (execute code without seeing output at runtime). | +| `autorun` | `false` | Allow `interactive` cells to be run during document initialization without a user pressing run code. | :::{.callout-note} -Options listed here are unique to the `{quarto-webr}` extension. For details regarding `context`, please see [Hiding and Executing Code](qwebr-internal-cell.qmd). +For details regarding run options, please see [Hiding and Executing Code](qwebr-internal-cell.qmd). ::: + +### Monaco Editor Options + +| Option | Default Value | Description | +|----------------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| + +| `read-only` | `false` | Prevent code in `interactive` cells from being modified by disallowing code input. | +| `editor-max-height` | `0` | Set a threshold to prevent infinite growth of the editor window. | +| `editor-quick-suggestions` | `false` | Show a list of autocomplete variables and/or functions based on what was typed. | + + + ## Attributes | Option | Default Value | Description | From b2423ba7155a223d43043793b8f569e3f9061421 Mon Sep 17 00:00:00 2001 From: James J Balamuta Date: Thu, 4 Apr 2024 21:10:04 -0700 Subject: [PATCH 3/7] Bump dev version --- _extensions/webr/_extension.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_extensions/webr/_extension.yml b/_extensions/webr/_extension.yml index 53ec6181..2c95d6eb 100644 --- a/_extensions/webr/_extension.yml +++ b/_extensions/webr/_extension.yml @@ -1,7 +1,7 @@ name: webr title: Embedded webr code cells author: James Joseph Balamuta -version: 0.4.2-dev.2 +version: 0.4.2-dev.3 quarto-required: ">=1.2.198" contributes: filters: From 15696044e9b08fabdcaf8f5ba069384ed61c1ef8 Mon Sep 17 00:00:00 2001 From: James J Balamuta Date: Thu, 4 Apr 2024 21:10:45 -0700 Subject: [PATCH 4/7] Add new cell key to Lua filter. --- _extensions/webr/webr.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_extensions/webr/webr.lua b/_extensions/webr/webr.lua index 2b046633..caed8f59 100644 --- a/_extensions/webr/webr.lua +++ b/_extensions/webr/webr.lua @@ -73,7 +73,8 @@ local qwebRDefaultCellOptions = { ["fig-height"] = 5, ["out-width"] = "700px", ["out-height"] = "", - ["editor-max-height"] = "" + ["editor-max-height"] = "", + ["editor-quick-suggestions"] = "false" } ---- From 225737b85696ef3c4282861cd74a6f598c863f25 Mon Sep 17 00:00:00 2001 From: James J Balamuta Date: Thu, 4 Apr 2024 21:14:23 -0700 Subject: [PATCH 5/7] Add test case --- tests/qwebr-test-editor-options.qmd | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/qwebr-test-editor-options.qmd b/tests/qwebr-test-editor-options.qmd index 3638ffa6..5135071f 100644 --- a/tests/qwebr-test-editor-options.qmd +++ b/tests/qwebr-test-editor-options.qmd @@ -8,8 +8,7 @@ filters: Check that the editor responses correctly to options being set. -## Interactive - +## Adaptive Container Constraints ### Single line @@ -17,10 +16,8 @@ Check that the editor responses correctly to options being set. print("test") ``` - ### Uncapped height - ```{webr-r} print("test") 59120 @@ -29,7 +26,6 @@ c(1, 3, 4) print("line 5") ``` - ### Height cap ```{webr-r} @@ -40,3 +36,14 @@ print("test") c(1, 3, 4) print("line 5") ``` + +## Autosuggetions + +Opt-in to auto suggestions. + +```{webr-r} +#| editor-quick-suggestions: true +my_long_variable = 1 + +prin +``` From 3f691bbd192ec61bd9ac6466328390325b2f89fc Mon Sep 17 00:00:00 2001 From: James J Balamuta Date: Thu, 4 Apr 2024 21:17:29 -0700 Subject: [PATCH 6/7] Add release note --- docs/qwebr-release-notes.qmd | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/qwebr-release-notes.qmd b/docs/qwebr-release-notes.qmd index 9edb7def..8b93bc84 100644 --- a/docs/qwebr-release-notes.qmd +++ b/docs/qwebr-release-notes.qmd @@ -8,7 +8,7 @@ format: toc: true --- -# 0.4.2-dev.2: ??????? (??-??-??) +# 0.4.2-dev.3: ??????? (??-??-??) :::{.callout-note} Features listed under the `-dev` version have not yet been solidified and may change at any point. @@ -18,9 +18,11 @@ Features listed under the `-dev` version have not yet been solidified and may ch - Added `cell-options` document-level option to specify global defaults for `{webr-r}` options ([#173](https://github.com/coatless/quarto-webr/pulls/173), thanks [ute](https://github.com/ute)!) -- Added `editor-max-height` cell option to limit growth of the editor window. ([#177](https://github.com/coatless/quarto-webr/pulls/173), thanks [ute](https://github.com/ute)!) +- Added `editor-max-height` cell option to limit growth of the editor window. ([#177](https://github.com/coatless/quarto-webr/issues/177), thanks [ute](https://github.com/ute)!) -- Added the ability to have the monaco editor switch between Quarto's light and dark theme modes. ([#176](https://github.com/coatless/quarto-webr/issues/176)) +- Added `editor-quick-suggestions` cell option to enable autocomplete menu suggestions. ([#182](https://github.com/coatless/quarto-webr/issues/182), thanks [egenn](https://github.com/egenn)!) + +- Added the ability to have the monaco editor switch between Quarto's light and dark theme modes. ([#176](https://github.com/coatless/quarto-webr/issues/176),) ## Bug fixes From 6710923f75c068c02bdc159c222ca05f1098ec14 Mon Sep 17 00:00:00 2001 From: James J Balamuta Date: Thu, 4 Apr 2024 21:18:41 -0700 Subject: [PATCH 7/7] Disable quick suggestions by default. --- _extensions/webr/qwebr-monaco-editor-element.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_extensions/webr/qwebr-monaco-editor-element.js b/_extensions/webr/qwebr-monaco-editor-element.js index fa372b86..4bd19339 100644 --- a/_extensions/webr/qwebr-monaco-editor-element.js +++ b/_extensions/webr/qwebr-monaco-editor-element.js @@ -30,7 +30,7 @@ globalThis.qwebrCreateMonacoEditorInstance = function (cellData) { renderLineHighlight: "none", // Disable current line highlighting hideCursorInOverviewRuler: true, // Remove cursor indictor in right hand side scroll bar readOnly: qwebrOptions['read-only'] ?? false, - quickSuggestions: qwebrOptions['editor-quick-suggestions'] ?? true + quickSuggestions: qwebrOptions['editor-quick-suggestions'] ?? false }); // Store the official counter ID to be used in keyboard shortcuts