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: image inline, refactor video upload #84

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions docs/.vitepress/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ export function getLocaleConfig(lang: string) {
text: 'Image',
link: '/extensions/Image/index.md',
},
{
text: 'ImageUpload',
link: '/extensions/ImageUpload/index.md',
},
{
text: 'Indent',
link: '/extensions/Indent/index.md',
Expand Down Expand Up @@ -216,10 +212,6 @@ export function getLocaleConfig(lang: string) {
text: 'Video',
link: '/extensions/Video/index.md',
},
{
text: 'VideoUpload',
link: '/extensions/VideoUpload/index.md',
},
{
text: 'Search And Replace',
link: '/extensions/SearchAndReplace/index.md',
Expand Down
14 changes: 11 additions & 3 deletions docs/extensions/Image/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
description: Image

next:
text: ImageUpload
link: /extensions/ImageUpload/index.md
text: Indent
link: /extensions/Indent/index.md
---

# Image
Expand All @@ -18,7 +18,15 @@ import { Image } from 'reactjs-tiptap-editor'; // [!code ++]
const extensions = [
...,
// Import Extensions Here
Image // [!code ++]
Image.configure({// [!code ++]
upload: (files: File) => {// [!code ++]
return new Promise((resolve) => {// [!code ++]
setTimeout(() => {// [!code ++]
resolve(URL.createObjectURL(files))// [!code ++]
}, 500)// [!code ++]
})// [!code ++]
},// [!code ++]
}),// [!code ++]
];
```

Expand Down
36 changes: 0 additions & 36 deletions docs/extensions/ImageUpload/index.md

This file was deleted.

14 changes: 11 additions & 3 deletions docs/extensions/Video/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
description: Video

next:
text: VideoUpload
link: /extensions/VideoUpload/index.md
text: SearchAndReplace
link: /extensions/SearchAndReplace/index.md
---

# Video
Expand All @@ -18,6 +18,14 @@ import { Video } from 'reactjs-tiptap-editor'; // [!code ++]
const extensions = [
...,
// Import Extensions Here
Video // [!code ++]
Video.configure({// [!code ++]
upload: (files: File[]) => {// [!code ++]
const f = files.map(file => ({// [!code ++]
src: URL.createObjectURL(file),// [!code ++]
alt: file.name,// [!code ++]
}))// [!code ++]
return Promise.resolve(f)// [!code ++]
},// [!code ++]
}), // [!code ++]
];
```
31 changes: 0 additions & 31 deletions docs/extensions/VideoUpload/index.md

This file was deleted.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
},
"dependencies": {
"@excalidraw/excalidraw": "^0.17.6",
"@radix-ui/react-checkbox": "^1.1.2",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-icons": "^1.3.0",
Expand Down Expand Up @@ -129,7 +130,8 @@
"shiki": "^1.22.0",
"svg64": "^2.0.0",
"tippy.js": "^6.3.7",
"valtio": "^1.13.2"
"valtio": "^1.13.2",
"y-prosemirror": "^1.2.12"
},
"devDependencies": {
"@antfu/eslint-config": "^2.27.3",
Expand Down
10 changes: 3 additions & 7 deletions playground/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import RichTextEditor, {
Iframe,
Image,
ImageGif,
ImageUpload,
ImportWord,
Indent,
Italic,
Expand All @@ -46,7 +45,6 @@ import RichTextEditor, {
TextDirection,
Underline,
Video,
VideoUpload,
locale,
} from 'reactjs-tiptap-editor'

Expand Down Expand Up @@ -102,8 +100,7 @@ const extensions = [
},
}),
Link,
Image,
ImageUpload.configure({
Image.configure({
upload: (files: File) => {
return new Promise((resolve) => {
setTimeout(() => {
Expand All @@ -112,8 +109,7 @@ const extensions = [
})
},
}),
Video,
VideoUpload.configure({
Video.configure({
upload: (files: File[]) => {
const f = files.map(file => ({
src: URL.createObjectURL(file),
Expand Down Expand Up @@ -179,7 +175,7 @@ const extensions = [
}),
]

const DEFAULT = `<h1 style="text-align: center">Rich Text Editor</h1><p>A modern WYSIWYG rich text editor based on <a target="_blank" rel="noopener noreferrer nofollow" class="link" href="https://github.com/scrumpy/tiptap">tiptap</a> and <a target="_blank" rel="noopener noreferrer nofollow" class="link" href="https://ui.shadcn.com/">shadcn ui</a> for Reactjs</p><p></p><p style="text-align: center"></p><div style="text-align: center;" class="image"><img height="auto" src="https://picsum.photos/1920/1080.webp?t=1" align="center" width="500"></div><p></p><div data-type="horizontalRule"><hr></div><h2>Demo</h2><p>👉<a target="_blank" rel="noopener noreferrer nofollow" class="link" href="https://reactjs-tiptap-editor.vercel.app/">Demo</a></p><h2>Features</h2><ul><li><p>Use <a target="_blank" rel="noopener noreferrer nofollow" class="link" href="https://ui.shadcn.com/">shadcn ui</a> components</p></li><li><p>Markdown support</p></li><li><p>TypeScript support</p></li><li><p>I18n support (vi, en, zh, pt)</p></li><li><p>React support</p></li><li><p>Slash Commands</p></li><li><p>Multi Column</p></li><li><p>TailwindCss</p></li><li><p>Support emoji</p></li><li><p>Support iframe</p></li></ul><h2>Installation</h2><pre><code class="language-bash">pnpm add reactjs-tiptap-editor</code></pre><p></p>`
const DEFAULT = ``

function debounce(func: any, wait: number) {
let timeout: NodeJS.Timeout
Expand Down
Loading
Loading