2017-04-06 1 views
0

저는 지난 몇 달 동안 CKEditor를 사용하고 있습니다.하지만 이제는 CKEditor에서 삭제할 문제가 있습니다.CKEDITOR : 마지막으로 삭제 된 요소 html 값을 얻으십시오.

입니다.

내 질문은 : 내가 CKEditor에서 마지막으로 삭제 된 요소의 HTML 값을받을 수 있나요 어떻게

. 내가 삭제 버튼을 클릭하면

, 나는

것은 삭제됩니다 및 요소 HTML 값을 삭제받을 요소가 무엇인지 싶어.

누구든지 도와주세요.

답변

1

당신이 에디터의 컨텐츠가 준비되면 리스너를 부착하고, 삭제 또는 백 스페이스를 눌러 확인하고 마지막으로 삭제 된 내용을 얻을 수 있습니다, 예를 들어 그것은 마법처럼 작품처럼 ::

CKEDITOR.replace('your-editor', { 
    ..., 
    on: { 
     contentDom: function() { //editor content ready 
      var myEditor = this; 
      //add listener 
      this.editable().attachListener(editor, 'key', function(evt) { 
       //if delete or backspace pressed 
       if ((evt.data.keyCode in { 8: 1, 46: 1 })) { 
        //get the last element 
        var lastElement = myEditor.elementPath().lastElement, 
         lastElementName = lastElement.getName(), 
         lastElementNode = lastElement.$; //native DOM object 
         //see what properties the node has 
         console.log(lastElementNode); 
         //you can use getAttribute to fetch specific attr 
         //for example, for img element's src attribute 
         console.log(lastElementNode.getAttribute("src")); 

       } 
      }); 
     } 
    } 
}); 
+0

bro.But 내가 원하는 수 또한 이미지를 삭제할 때 그 세부 정보를 얻지 못합니다. 내 이미지 태그 값은 '' –

+0

입니다. ** lastElementNode ** 값은 everyTime에서 null입니다. –

+0

@MariSelvan이 http://jsfiddle.net/0Lkvq69f/4/를 확인하십시오. 잘 작동합니다. –