Skip to content

feat: allow multiple references in citation#310

Merged
cguedes merged 23 commits into
mainfrom
287-allow-multiple-references-in-citation
Jul 20, 2023
Merged

feat: allow multiple references in citation#310
cguedes merged 23 commits into
mainfrom
287-allow-multiple-references-in-citation

Conversation

@sehyod

@sehyod sehyod commented Jul 18, 2023

Copy link
Copy Markdown
Collaborator

Closes #287

This adds a new citation node, that contains text and references.
The node can be created by typing [ in the document.
references can now be inserted with the character @, but only in citation nodes
Inserting a citation automatically opens the reference picker
When at the end of a citation node, after a reference, typing anything will add ; before the added content

Screen.Recording.2023-07-18.at.12.26.43.mov

NB: References are now rendered with a React component, which means we can completely customise them, for example by having the name of the reference instead of the citation key, and making them hyperlinks that open the corresponding document. This also means that updating a reference in the reference table now updates it in the editor too.

@codecov

codecov Bot commented Jul 18, 2023

Copy link
Copy Markdown

Codecov Report

Merging #310 (2761542) into main (dacd1a2) will increase coverage by 2.01%.
The diff coverage is 99.77%.

@@            Coverage Diff             @@
##             main     #310      +/-   ##
==========================================
+ Coverage   86.47%   88.48%   +2.01%     
==========================================
  Files         137      144       +7     
  Lines        7577     7949     +372     
  Branches      833      927      +94     
==========================================
+ Hits         6552     7034     +482     
+ Misses       1011      901     -110     
  Partials       14       14              
Impacted Files Coverage Δ
...Editor/components/tipTapNodes/references/config.ts 100.00% <ø> (ø)
...components/tipTapNodes/references/ReferenceNode.ts 98.83% <98.83%> (ø)
...tures/textEditor/components/tipTapEditorConfigs.ts 83.07% <100.00%> (+0.53%) ⬆️
...ditor/components/tipTapNodes/citation/Citation.tsx 100.00% <100.00%> (ø)
...or/components/tipTapNodes/citation/CitationNode.ts 100.00% <100.00%> (ø)
...citation/inputRuleHandlers/squareBracketHandler.ts 100.00% <100.00%> (ø)
...es/citation/keyboardShortcutCommands/arrowRight.ts 100.00% <100.00%> (ø)
...des/citation/keyboardShortcutCommands/backspace.ts 100.00% <100.00%> (ø)
...apNodes/citation/keyboardShortcutCommands/enter.ts 100.00% <100.00%> (ø)
...or/components/tipTapNodes/references/Reference.tsx 100.00% <100.00%> (ø)
... and 3 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@hammer

hammer commented Jul 18, 2023

Copy link
Copy Markdown
Contributor

References are now rendered with a React component, which means we can completely customise them, for example by having the name of the reference instead of the citation key, and making them hyperlinks that open the corresponding document. This also means that updating a reference in the reference table now updates it in the editor too.

nice! Check out CSL for where we are going next … https://citationstyles.org/

@sehyod sehyod requested a review from cguedes July 19, 2023 12:33
@sehyod sehyod marked this pull request as ready for review July 19, 2023 12:33
cguedes
cguedes previously approved these changes Jul 19, 2023

@cguedes cguedes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work 👏 .

Just a note about which HTML element should we use for citations and some couple minor comments.

Comment thread src/features/textEditor/components/tipTapEditorConfigs.ts Outdated
* Plugin that prevents the cursor from being directly after the opening and closing brackets of citation nodes
*/
const moveCursorPluginKey = new PluginKey('moveCursor');
const moveCursorPlugin = new Plugin({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not directly related to this (I think!) but can we make the cursor | visible inside the citation node?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that is really annoying but I don't see any easy fix. The issue is that when there is a reference node followed by the end of the citation node, there is no text node in between (because empty text nodes are not valid), so the cursor doesn't show

Comment thread src/features/textEditor/components/tipTapNodes/references/ReferencesList.tsx Outdated
@cguedes cguedes merged commit abab099 into main Jul 20, 2023
@cguedes cguedes deleted the 287-allow-multiple-references-in-citation branch July 20, 2023 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow for multiple references to be included in a single citation

3 participants