비

스마트에디터2 내용물 외부에서 바꾸기

write.skin.php 기준입니다. php 가 아니라 자바스크립트입니다.

스마트에디터는 아이프레임으로 불러오기 때문에 아이프레임 온로드 이후에 해당코드를 넣어야 합니다.

 

<script>
document.addEventListener("DOMContentLoaded", () => {
    wr_content.nextSibling.onload = function() {

        해당코드;
    }
});
</script>

 

----------

 

oEditors.getById["wr_content"].exec("SET_IR", [""]); 
// 에디터 내용 전부 삭제

 

oEditors.getById["wr_content"].exec("PASTE_HTML", ["그누보드 만만세"]); 
// 커서 위치에 그누보드 만만세 입력

 

oEditors.getById["wr_content"].getIR();
// 에디터의 현재 내용 얻기

 

----------


1) 현재 커서 위치에 유튜브를 넣으려면?
oEditors.getById["wr_content"].exec("PASTE_HTML", ["유튜브 아이프레임"]);

 

2) 내용물을 몽땅 지우고 유튜브를 넣으려면?

oEditors.getById["wr_content"].exec("SET_IR", ["유튜브 아이프레임"]);

 

3) 내용물을 유지시키면서 처움에 유튜브를 넣으려면?
saveData = oEditors.getById["wr_content"].getIR();
oEditors.getById["wr_content"].exec("SET_IR", ["유튜브 아이프레임" + saveData]);

 

4) 내용물을 유지시키면서 마지막에 유튜브를 넣으려면?
saveData = oEditors.getById["wr_content"].getIR();
oEditors.getById["wr_content"].exec("SET_IR", [saveData + "유튜브 아이프레임"]);

|

댓글 7개

감사 합니다.

@들레아빠 감사합니다

@트리플 감사합니다 

그런데 

 

document.addEventListener("DOMContentLoaded", () => {

 

1번위치


    document.querySelector("#wr_content").style.height = "<?php echo $se2_height; ?>";
    document.querySelector("#commentEditor iframe").onload = function() {
        se2Custom = this["contentWindow"]["document"];
        se2Custom.querySelector("body").style.backgroundColor = "#ffffff";
        se2Custom.querySelector("#smart_editor2 .se2_text_tool .se2_multy").style.display = "<?php echo $upload_display; ?>";
        se2Custom.querySelector("#smart_editor2 #se2_iframe").onload = function() {
            this["contentWindow"]["document"].querySelector("body").insertAdjacentHTML("beforebegin", "<style>img { max-width:100%; }</style>");
        }
    }
} );
</script>
<!-- /wittazzurri_5 -->
 

 

    wr_content.nextSibling.onload = function() {

oEditors.getById["wr_content"].exec("PASTE_HTML", ["그누보드 만만세"]); 
    } 요거를

1번 위치부터 한줄한줄 넣어봐도 만만세는 커녕 개미한마리 안보이는데요? ㅎ

@뽕엄능브라

write.skin.php 와 댓글란은 적용할 대상이 다른데 코멘트 영역에서 저걸 쓰면 개미가 아니라 박테리아 한마리도 나타나지 않는 것은 지극히 정상입니다.

그리고 이건 온클릭 같은 트리거를 거쳐야만 일어나고요.

에디터는 백퍼센트 자바스크립트이니 php 를 적용하는 방식과는 많이 다르죠.

애초에 제이쿼리 없는 바닐라로만 적용했으니 응용하고 싶다면 바닐라 즉 순수 자바스크립트의 알고리즘을 익히시길 권합니다.

@비타주리 댓글에디터도 주시고 답변도 해주시고ㅎㅎ  감사합니다

댓글을 작성하시려면 로그인이 필요합니다.
+
제목 글쓴이 날짜 조회
24-03-29 조회 4,453
24-03-27 조회 5,138
24-03-27 조회 5,008
24-03-27 조회 5,465
24-03-22 조회 4,591
24-03-19 조회 4,116
24-03-19 조회 1만
24-03-15 조회 4,904
24-03-15 조회 4,440
24-03-15 조회 4,319
24-03-15 조회 4,328
24-03-13 조회 4,937
24-03-05 조회 4,384
24-03-01 조회 4,428
24-02-29 조회 6,498
24-02-29 조회 5,614
24-02-28 조회 4,876
24-02-27 조회 4,959
24-02-24 조회 4,582
24-02-18 조회 5,180
24-02-17 조회 4,171
24-02-15 조회 4,557
24-02-14 조회 4,025
24-02-13 조회 7,465
24-02-05 조회 4,702
24-01-31 조회 4,917
24-01-30 조회 4,264
24-01-30 조회 4,844
24-01-27 조회 4,717
24-01-18 조회 5,275