监控ckeditor内容变化,删除编辑器内图片,ueditor同样适用

2019-09-29 14:22:23 浏览数 (1)

代码语言:javascript复制
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 });

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

0 人点赞