Skip to content
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

feat: save as markdown behaviour for web #472

Merged
merged 11 commits into from
Sep 1, 2023

Conversation

cguedes
Copy link
Collaborator

@cguedes cguedes commented Sep 1, 2023

This PR fixes #455 by implementing the same codebase for desktop and web, saving the files (markdown, and optionally the .bib) in the exports folder inside the project.

We can't add the operation to the explorer context menu because we can't ensure that the entry is hidden/inactive for other file types (pdf, .md), and also the current codebase exports the active editor (has a dependency on the TipTap editor instance)

image

image

@cguedes cguedes linked an issue Sep 1, 2023 that may be closed by this pull request
@cguedes cguedes requested a review from sehyod September 1, 2023 13:21
@codecov
Copy link

codecov bot commented Sep 1, 2023

Codecov Report

Merging #472 (2f918c1) into main (303c46a) will increase coverage by 0.13%.
Report is 1 commits behind head on main.
The diff coverage is 33.33%.

@@            Coverage Diff             @@
##             main     #472      +/-   ##
==========================================
+ Coverage   80.32%   80.45%   +0.13%     
==========================================
  Files         188      189       +1     
  Lines       11151    11160       +9     
  Branches     1077     1082       +5     
==========================================
+ Hits         8957     8979      +22     
+ Misses       2180     2167      -13     
  Partials       14       14              
Files Changed Coverage Δ
src/application/App.tsx 0.00% <0.00%> (ø)
src/io/__mocks__/filesystem.ts 100.00% <ø> (ø)
src/api/projectsAPI.ts 28.57% <3.44%> (-3.41%) ⬇️
src/features/textEditor/saveAsMarkdown.tsx 15.38% <15.38%> (ø)
...rc/features/textEditor/components/TipTapEditor.tsx 88.88% <57.14%> (-1.50%) ⬇️
src/io/filesystem.ts 86.61% <83.33%> (+17.46%) ⬆️

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

@@ -102,3 +108,26 @@ export function TipTapEditor({ editorContent, editorId, isActive, saveFileInMemo
</div>
);
}

export async function saveAsMarkdown(markdownSerializer: MarkdownSerializer, filePath: string) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've moved this file here as he depends in the markdownSerializer that belong to the "text editor".
I've also simplified the code by using the new getFileNameAndExtension.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After our chat I moved this to own file in src/features/textEditor

@@ -81,14 +85,31 @@ export async function readProjectFiles(projectId: string): Promise<TauriFileEntr
children: undefined,
}));

const exportsFiles = relativePaths
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've added this support while we don't have #414 ready.

@@ -43,7 +43,7 @@ export function App() {
);

useEventListener('unhandledrejection', (event) => {
notifyError('An error occurred', `Unhandled rejection in promise. Reason: ${event.reason}).`);
notifyError('Unhandled rejection in promise', `Reason: ${event.reason}`);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Improve this a bit further.

src/features/textEditor/components/TipTapEditor.tsx Outdated Show resolved Hide resolved
@cguedes cguedes marked this pull request as ready for review September 1, 2023 13:39
src/features/textEditor/components/TipTapEditor.tsx Outdated Show resolved Hide resolved
src/io/filesystem.ts Outdated Show resolved Hide resolved
@cguedes cguedes requested a review from sehyod September 1, 2023 16:05
@cguedes cguedes merged commit 43e1000 into main Sep 1, 2023
10 checks passed
@cguedes cguedes deleted the 455-save-as-markdown-behaviour-for-web branch September 1, 2023 16:25
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.

Save as Markdown behaviour for web
2 participants