Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
lib
react-ag-qeditor
Commits
dd70d3d0
Commit
dd70d3d0
authored
Jun 27, 2025
by
Яков
Browse files
fix drag and drop
parent
4011a958
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/extensions/DragAndDrop.js
View file @
dd70d3d0
...
...
@@ -20,31 +20,31 @@ const DragAndDrop = Extension.create({
key
:
new
PluginKey
(
'
customDragAndDrop
'
),
props
:
{
handleDOMEvents
:
{
//
async paste (view, event) {
//
//
console.log(event.clipboardData);
//
//
console.log(
event.originalEvent.clipboardData
);
//
//
let items = (event.clipboardData || event.originalEvent.clipboardData).items;
//
//
for (let i = 0; i < items.length; i++){
//
const { schema } = view.state;
//
const image = items[i].getAsFile();
//
//
if (!image) {
//
return
//
}
//
//
// event.preventDefault();
//
const imageSrc = await upload(image);
//
//
const node = schema.nodes.image.create({
//
src: imageSrc,
//
});
//
const transaction = view.state.tr.replaceSelectionWith(node);
//
view.dispatch(transaction)
//
}
//
},
async
paste
(
view
,
event
)
{
console
.
log
(
'
Clipboard types:
'
,
event
.
clipboardData
.
types
);
console
.
log
(
'
HTML data length:
'
,
event
.
clipboardData
.
getData
(
'
text/html
'
).
length
);
//
let items = (event.clipboardData || event.originalEvent.clipboardData).items;
//
//
for (let i = 0; i < items.length; i++){
//
const { schema } = view.state;
//
const image = items[i].getAsFile();
//
//
if (!image) {
//
return
//
}
//
//
// event.preventDefault();
//
const imageSrc = await upload(image);
//
//
const node = schema.nodes.image.create({
//
src: imageSrc,
//
});
//
const transaction = view.state.tr.replaceSelectionWith(node);
//
view.dispatch(transaction)
//
}
},
async
drop
(
view
,
event
)
{
const
hasFiles
=
event
.
dataTransfer
.
files
.
length
>
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment