監控ckeditor內容變化,刪除編輯器內圖片,ueditor一樣適用

let body = document.querySelector("iframe").contentDocument.body;
let observer = new MutationObserver((mutationsList, observer) => {
  for (let mutation of mutationsList) {
    if (mutation.removedNodes.length > 0) {
      console.log(mutation);
      console.log(mutation.removedNodes)
    }
  }
});
observer.observe(body, { subtree: true, childList: true });

以上是監控代碼;
刪除圖片的代碼沒有包含在內,本身控制javascript

相關文章
相關標籤/搜索