2011-02-15 3 views
0

저는 ckeditor로 작업 중이며 사용자 정의 플러그인을 작성하여 페이지의 앵커에 대한 링크를 정의합니다. 이제 내 페이지의 모든 앵커를 얻으려고하면 아무 것도 반환되지 않습니다.ckeditor 문서에서 앵커 가져 오기

<p> 
    <a name="anchor-anchor"></a></p> 

을하지만이 같은 문서의 모든 앵커을 얻을 때 :
editor.document.getElementsByTag("a")

아무것도 반환되지 않습니다 다음과 같이

내 HTML 보인다. 하지만 일반적인 앵커를 배치하면 위의 코드에서이를 발견 할 수 있습니다. 내가 잘못하고 있니?

감사합니다.

답변

3

이 바로 링크 대화 상자에서입니다 :

// Find out whether we have any anchors in the editor. 
    // Get all IMG elements in CK document. 
    var elements = editor.document.getElementsByTag('img'), 
     realAnchors = new CKEDITOR.dom.nodeList(editor.document.$.anchors), 
     anchors = retval.anchors = []; 

    for (var i = 0; i < elements.count() ; i++) 
    { 
     var item = elements.getItem(i); 
     if (item.data('cke-realelement') && item.data('cke-real-element-type') == 'anchor') 
      anchors.push(editor.restoreRealElement(item)); 
    } 

    for (i = 0 ; i < realAnchors.count() ; i++) 
     anchors.push(realAnchors.getItem(i)); 

    for (i = 0 ; i < anchors.length ; i++) 
    { 
     item = anchors[ i ]; 
     anchors[ i ] = { name : item.getAttribute('name'), id : item.getAttribute('id') }; 
    } 
관련 문제