Comments (2)
This works too
useEffect(() => {
const handlePaste = async (event) => {
const clipboardData = event.clipboardData || window.clipboardData;
if (clipboardData && clipboardData.items) {
for (const item of clipboardData.items) {
if (item.type.indexOf('image') !== -1) {
const blob = item.getAsFile();
const reader = new FileReader();
reader.onload = () => {
const base64Data = reader.result.split(',')[1];
// console.log('Base64 Image Data:', base64Data);
uploadImageToAPI(base64Data, event)
};
reader.readAsDataURL(blob);
}
}
} else {
// console.log('Text Data:', clipboardData.getData('text'));
}
};
const textInput = document.querySelector('.w-md-editor-text-input');
if (textInput) {
textInput.addEventListener('paste', handlePaste);
}
return () => {
if (textInput) {
textInput.removeEventListener('paste', handlePaste);
}
};
}, []);
I also added a little loader in the toolbar :
const upload = {
name: "upload",
keyCommand: "upload",
buttonProps: { "aria-label": "Insert help" },
icon: (
<div className="material-icons-outlined" style={{fontSize:'12px',animation:'spin 2s linear infinite',display:['none','block'][uploading]}}>cached</div>
),
};
from react-md-editor.
Related Issues (20)
- Can't resolve 'devlop' for ./node_modules/hast-util-from-html/lib/index.js on version 4.0.1 HOT 3
- Issue on long text HOT 6
- Using `prose` from `tailwind/typography` HOT 5
- Module '"@uiw/react-markdown-preview/nohighlight"' has no exported member 'MarkdownPreviewProps' HOT 2
- 设置指定maxheight后, 全屏显示情况下,编辑区域并不是全屏高度 HOT 2
- Embedded base64 images are not working after update from 3.26.5 to 4.0.1 HOT 9
- Next.js problem while writing an article HOT 6
- ul li tag automatically created HOT 2
- toolbar只使用部分功能 HOT 3
- skipHtml not working
- Controlled toolbar? HOT 1
- Bug: When I push (option+ ₩) + (option + Enter) in MacOS, the cursor is broken HOT 1
- blinking cursor not showing inside md editor when placed in overflows modal HOT 1
- The editor is stuck When value is large HOT 1
- 工具栏提示如何设置中文 HOT 2
- Spell Checker/ Auto Correct? HOT 1
- 预览标题的时候可以屏蔽链接标识吗 HOT 1
- Missing Source Map Files for parse5 in hast-util-raw Dependencies HOT 4
- How can i set textarea(.w-md-editor-text-input)'s parent <div> height style? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-md-editor.