Skip to content

功能:禁止用户拖拽内容进编辑器 #303

Closed Answered by cycleccc
xixihhhh asked this question in Q&A
Discussion options

You must be logged in to vote

根据容器 id 自行禁止拖拽事件如:

document.getElementById('editor-text-area').addEventListener(
  'drop',
  (e) => {
    e.preventDefault();
    e.stopPropagation();
  },
  { capture: true }
);
document.getElementById('editor-text-area').addEventListener(
  'dragover',
  (e) => {
    e.preventDefault();
    e.stopPropagation();
  },
  { capture: true }
);

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by cycleccc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request
2 participants
Converted from issue

This discussion was converted from issue #227 on October 29, 2024 07:27.