버전 4.1 이후, CKEditor 그렇게 Content Transformations라고 이미 그 중 일부를 정의하고 제공 감사드립니다. config.allowedContent
에서 width
및 height
을 <img>
스타일에 포함하지 않으려면 편집기가 자동으로 스타일을 속성으로 변환합니다.
CKEDITOR.replace('editor1', {
allowedContent:
'img[!src,alt,width,height]{float};' + // Note no {width,height}
'h1 h2 div'
});
다음 : 예를 들어 내가 추측으로, 완전히 문제를 해결,
<p><img alt="Saturn V carrying Apollo 11" height="250" src="assets/sample.jpg" width="200" /></p>
과 :
<p><img alt="Saturn V carrying Apollo 11" class="left" src="assets/sample.jpg" style="height:250px; width:200px" /></p>
는 출력이됩니다.
를 지금까지 그들이 당신의 규칙에 의해 허용되지 않습니다 때문에 나는, 그것은 또한 당신의'p' 태그를 제거해야 볼 수 있습니다. 나는 가능한 모든 태그와 attr의 몬스터 화이트리스트를 필요로하지 않고이 변환을하고 싶다. 즉, 'allowedContent : true'를 사용하면된다. 'CKEDITOR.on ('instanceReady ', function (ev) {ev.editor .filter.addTransformations ([[ 'img : sizeToAttribute']]);}); ' 항상 스타일을 속성으로 변환하지만 아무 것도하지 않습니다. – Synchro
FYI'p'는 must-have 태그로 편집기에서 추가됩니다.'config.enterMode'는'ENTER_P'입니다. – oleq
@Synchro는 정확합니다.'allowedContent'를 사용하면 모든 태그와 속성을 화이트리스트해야합니다. 더 적합한 대체 솔루션을 게시했습니다. –