add standalone insert citation dialog for hosts without an editor - #1126
Open
kevinushey wants to merge 1 commit into
Open
kevinushey wants to merge 1 commit into
kevinushey wants to merge 1 commit into
Conversation
The Insert Citation dialog only used the ProseMirror document to read the YAML front matter, and the command applied the result with a transaction. Let the bibliography manager accept YAML blocks directly, split the bibliography writes out of ensureSourcesInBibliography, and export an InsertCitationDialog class (also from the panmirror bundle) that returns the citation ids and any bibliography file the host should declare, so plain-text hosts can offer the dialog. Addresses rstudio/rstudio#7876.
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes the visual editor's Insert Citation dialog usable without an editor instance, so RStudio can offer it in its plain-text source editor (rstudio/rstudio#7876, a long-standing request).
The dialog itself never needed the ProseMirror document. It only read the YAML front matter to find
bibliography:,references:andzotero:.InsertCitationCommandthen applied the result with a transaction: the[@key]text and, when a new bibliography file was created, abibliography:line in the front matter. This PR separates those two seams from the rest.Changes
BibliographyManagerand its providers accept either a document or plain YAML blocks (YamlBlockSource). Existing callers keep passing the doc and are unchanged.ensureSourcesInBibliographyis split. The newwriteSourcesToBibliographydoes the server writes and the Better BibTeX warning, and the wrapper still addsbibliography:to the doc in the same transaction.showInsertCitationDialogtakes aYamlBlockSource. The unuseddocparameter is removed from the panel and the bibliography source panel.InsertCitationDialogclass (editor/editor-citation.ts) is exported fromeditorand from the panmirror bundle.show({ yaml, theme?, selectionKey? })returns{ citationIds, intextCitationStyle, bibliographyFile?, selectionKey? }. The host inserts the citation text and declaresbibliographyFilein its front matter when set.editorUIWithDefaultImagesis extracted fromEditor.create. This also corrects theomni_insertandcitationsmerges, which spread the wholeimagesobject instead of the nested one.editor-uipasses the full defaults, so its images are unchanged.ensureThemeapplies the default theme CSS when no editor has applied a theme yet, since the panel relies on thepm-*color classes.Verification
tsc --noEmitpasses forapps/panmirrorandapps/vscode-editor, and eslint passes on the changed files.Standalone dialog. I loaded the built bundle in headless Chromium with a stub host and server and drove the dialog:
bibliography:citationIds: ["smith2020"],bibliographyFile: "references.bib"refs.bibcitationIds: ["rivera2021"], nobibliographyFilerefs.bibnullVisual editor, before and after. In an RStudio development server, I inserted an R Package citation from the visual editor's Insert Citation dialog in a new
.mddocument. I ran it once with the current bundle and once with this branch's bundle served in its place:[@knitr]insertedbibliography: references.bibaddedreferences.bibhas the knitr entryNotes
apps/vscode/CHANGELOG.mdentry, because nothing changes for VS Code or Positron users. The new export is for RStudio. Happy to add one if you'd prefer.packages/editor-collabandpackages/editor-codemirrortype-checkeditor/srcwithout JSX enabled, so theirtscalready reports TS6142 for the.tsxmodules it reaches. The new file adds one more of the same, and neither package has atscscript or CI step.