监控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 });

以上是监控代码;
删除图片的代码没有包含在内,自己控制

猜你喜欢

转载自www.cnblogs.com/liulun/p/11470807.html