Skip to content

Commit

Permalink
feat: 根据全局设置body.contentEditable是否可编辑,判定为富文本编辑器
Browse files Browse the repository at this point in the history
  • Loading branch information
王美建 committed Dec 13, 2022
1 parent 0f53cd1 commit 29ff836
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions extension/content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,16 @@ class AutoClipboard {
// 是否富文本编辑器
const isRichTextEditor = () => {
const activeElement = document.activeElement;
const isBodyContentEditable = document.body.isContentEditable || document.designMode === 'on';
const isElementContenteditable = (element) => {
if (!element || element.parentElement === null) return false;

return (
element.getAttribute("contenteditable") === "true" ||
element.isContentEditable ||
isElementContenteditable(element.parentElement)
);
};
return isElementContenteditable(activeElement);
return isBodyContentEditable || isElementContenteditable(activeElement);
};
const storage = await chrome.storage.sync.get(['copy', 'whitelist']);
const currenthost = new URL(location.href).origin;
Expand Down

0 comments on commit 29ff836

Please sign in to comment.