[에디터] CKeditor4.x 에디터 툴바 고정하기

페이지 정보

yadolee 루루아빠 3,952 1 2016.05.24 01:32:05

평점

  • 평점 : 0점 (0명 참여)

본문

CKeditor4.x 에디터 사용시 본문이 길 경우 툴바 메뉴를 사용하기 위해 마우스 휠을 사용해야 하는 수고스러움이 있다.
그 수고스러움을 덜어보자

1. 그누보드5/plugin/CKeditor4.x/config.js 를 열어 소스 가장 하단 }; 바로 위쪽에 다음 소스를 추가한다.

window.CKEDITOR.on('instanceReady', function () {
    var toolbar = document.getElementsByClassName('cke_top').item(0),
                  boxTop = toolbar.getBoundingClientRect().top,
                  offsetTop = 45; // toolbar offset top

    window.addEventListener('scroll', function () {
        window.requestAnimationFrame(function () {
            var scrollTop =document.body.scrollTop;
            if ((scrollTop + offsetTop) > boxTop) {
                toolbar.style.top = scrollTop + offsetTop - boxTop + 'px';
            } else {
                toolbar.style.top = 0;
            }
        });
    }, false);
});
2. 동일 폴더 contents.css 를 열어 다음 스타일을 추가한다.


.cke_top {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    will-change: top;
}

추천인
  • 추천해 주세요
yadolee
6
루루아빠 - 회원등급 : 최고관리자 - 포인트 : 1,332,814
레벨 100
경험치 1,488,440

Progress Bar 11.47%

- 가입일 : 2015-03-04 03:24:54
- 서명 : KNOW YOUR LIMITS BUT NEVER STOP TRYING TO EXCEED THEM !!
- 자기소개 : 루루의 자랑 루루아빠랍니다~~

댓글1

루루아빠님의 댓글

yadolee
루루아빠 글쓴이 2016.06.01 01:35
상기 소스를 이용하는 것보다 플러그인을 활용하는 게 더 효과적이였다. http://ckeditor.com/addon/fixed 상기 애드온을 다운 받아 소스를 plugin.js 를 아래 소스롤 덮어 씌워 사용하자



CKEDITOR.plugins.add( 'fixed', {
    init: function( editor ) {
      editor.on('instanceReady', function (readyEvent) {
        if (CKEDITOR.toolbarFixer == undefined) {      // To prevent double activation - event listener and its handler should be set only once
          CKEDITOR.toolbarFixer = function toolbarFixerF(event) {
            for(var i=0; i document.body.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;

              toolbar.style.width = content.offsetWidth + "px";
              toolbar.style.top = "0px";
              toolbar.style.left = "0px";
              toolbar.style.right = "0px";
              toolbar.style.margin = "0 auto";
              toolbar.style.boxSizing = "border-box";

              if (editor.offsetTop <= scrollvalue && (editor.offsetTop + editor.offsetHeight) > (scrollvalue + toolbar.offsetHeight + 100)) {
                toolbar.style.position = "fixed";
                content.style.marginTop = toolbar.offsetHeight + "px";
              } else {
                toolbar.style.position = "relative";
                content.style.marginTop = "0px";
              }
            }
          };
          CKEDITOR.toolbarFixer.ckeRootNodes = [];
          window.addEventListener('scroll', CKEDITOR.toolbarFixer, false);
        }
        CKEDITOR.toolbarFixer.ckeRootNodes.push(readyEvent.editor.container.$);
        readyEvent.editor.container.$.getElementsByClassName('cke_top').item(0).style.zIndex = 100;    // For codemirror plugin compatibility
      });
    }
});

Total 7622239 페이지

제목 글쓴이 날짜 조회 추천
그누•영카트  🏆 내용에 올바르지 않은 코드가 다수 포함되어 있습니다 - 해결법 루루아빠 2015.05.26 3,864 0
그누•영카트  🏆 그누보드 5.2.1 패치 루루아빠 2016.08.22 2,659 0
이윰  댓글+1🏆 게시글 제목과 상단과의 간격 조정 루루아빠 2015.05.27 2,852 0
그누•영카트  🏆 영카트 5.2.1 패치 루루아빠 2016.08.22 2,853 0
그누•영카트  🏆 5.2.1 토큰패치로 댓글 달린 본인 댓글 수정 못하는 문제 루루아빠 2016.08.22 2,828 0
이윰  댓글+1🏆 Responsive Video와 게시글 정보와의 간격 조정 루루아빠 2015.05.27 3,350 0
이윰  🏆 Google Maps API Key를 발급받아 이윰 스킨에 적용하기 루루아빠 2016.08.24 5,652 0
이윰  🏆 태그 더보기시 페이지당 태그 노출 갯수 조정하기 루루아빠 2016.08.25 3,082 0
이윰  댓글+1🏆 이윰빌더 1.1.1 대응 스킨 패치 루루아빠 2015.05.27 3,203 0
이윰  🏆 Eyoom Builder 1.2.6 패치 루루아빠 2016.08.26 2,839 0
이윰  🏆 그누 5.2.1 패치로 비회원 댓글 작성시 오류 메세지 띄우는 문제 루루아빠 2016.09.04 3,055 0
JavaScript  댓글+3🏆 단축키로 페이지 이동 루루아빠 2015.05.28 4,398 0
에디터  🏆 CKeditor4.x 에디터 툴바 고정후 스크롤시 firefox에서 가로폭 늘어나는 문제 해결 루루아빠 2016.09.18 3,533 0
그누•영카트  🏆 그누보드 5.2.2 패치 루루아빠 2016.09.20 2,830 0
그누•영카트  🏆 📸 5.3.3.3 버전 에서 5.4.1 정식버전으로 패치 shadow2fox 2019.12.03 1,958 0
이윰  🏆 📸 인터넷익스플로어에서 회원가입 폼 '정보공개' 체크 안되는 점 수정 루루아빠 2015.05.29 3,231 0
그누•영카트  🏆 영카트 5.2.2 쿠폰존 기능추가 루루아빠 2016.09.20 3,412 0
그누•영카트  🏆 그누보드 5.4.1.1 shadow2fox 2019.12.03 2,254 0
그누•영카트  🏆 자신의 댓글에 댓글이 달리면 본인 댓글 수정 못하는 문제 루루아빠 2015.05.30 3,219 0
이윰  🔒 쇼핑몰 테마 메인 화면을 쇼핑몰로 바꾸기 루루아빠 2016.09.24 4 0