steven-tey / novel

Notion-style WYSIWYG editor with AI-powered autocompletion.
https://novel.sh
Apache License 2.0
13.25k stars 1.08k forks source link

Add basic support for pasting markdown text #189

Closed arrlancore closed 1 year ago

arrlancore commented 1 year ago

This pull request introduces an initial feature that enables users to paste text in Markdown format directly into the editor (like notion editor). This enhancement aims to improve the user experience by allowing seamless integration and content transfer between Markdown files to novel.

The current implementation covers all basic Markdown formats including:

Before

screencapture-novel-sh-2023-10-03-14_03_27

After

screencapture-redesigned-barnacle-q7qvr477wq4c6x77-3000-app-github-dev-2023-10-03-14_03_53

vercel[bot] commented 1 year ago

@arrlancore is attempting to deploy a commit to the Elegance Team on Vercel.

A member of the Team first needs to authorize it.

arrlancore commented 1 year ago

Here is the testing text that I use for:

# Welcome to Test Paste MD
# H1 Header Example
## H2 Header Example
### H3 Header Example
***
#### H4 Header Example `h4`
##### H5 Header Example `h5`
###### H6 Header Example `h6`
---
## Paragraphs
This is a sample paragraph. It includes text that is **bold**, *italic*, and ~~strikethrough~~. We can also include `inline code`.
## [Links](http://example.com)
Here is an [inline link](http://example.com).
## Image
![Alt text](https://dummyimage.com/600x250/333/fff)
___
## Lists
### Unordered List
- Item 1
- Item 2
### Ordered List
1. First item
2. Second item [link](http://example.com)
## Task Lists
- [x] Completed task `done`
- [ ] Incomplete task
## Blockquotes
> This is a single-line blockquote.

> This is a multiline blockquote. It spans **bold**
> multiple lines to demonstrate this capability.
## Fenced Code Block
```javascript
console.log('Hello, world 1');
console.log('Hello, world 2');```
jt6677 commented 1 year ago

good man

steven-tey commented 1 year ago

@arrlancore first of all, thank you so much for the PR – huge kudos to you for taking the effort here!

We're actually using the amazing https://github.com/aguingand/tiptap-markdown package by @aguingand for this so was able to enable this in a one-line PR over at #191.

Highly recommend you taking this over to the tiptap-markdown package and see if there's anything that can be improved there though!

arrlancore commented 1 year ago

Ah I see, I dont actually check the internal lib like tiptap markdown. I just test the current version at novel.sh, checking issue and PR. But I like if there already have one-line solution and it's also better approach, while I also learn how it work behind the scene.

Btw is there any plan to support table for the editor @steven-tey ? I think we can use tiptap table extention for it. And I will be happy to work on it.