본문 바로가기

Story/php

wysiwyg SPAW Editor style change 시에 span 태그 추가하기

반응형

spaw/class/script.js.php 파일에
function SPAW_style_change(editor, sender)
....

이 함수를 다음과 같이 수정해준다.

function SPAW_style_change(editor, sender)
{

 classname = sender.options[sender.selectedIndex].value;

 window.frames[editor+'_rEdit'].focus();

 if (this[editor+'_rEdit'].document.selection.type.toLowerCase() == "text"){
  var selection = window.frames[editor+'_rEdit'].document.selection.createRange();
  var newspan = document.createElement('SPAN');
  newspan.innerHTML=selection.htmlText;
  newspan.className=classname;
  selection.pasteHTML(newspan.outerHTML);
 } else {
  var el = SPAW_getParentTag(editor);
  if (el != null && el.tagName.toLowerCase() != 'body'){
   if (classname != 'default') el.className = classname;
   else
   if (el.tagName.toLowerCase() == 'span') el.removeNode();
   else
   el.removeAttribute('className');
  } else if (el.tagName.toLowerCase() == 'body'){
   if (classname != 'default')
    this[editor+'_rEdit'].document.body.innerHTML = '<p class="'+classname+'">'+this[editor+'_rEdit'].document.body.innerHTML+'</p>';
   else
    this[editor+'_rEdit'].document.body.innerHTML = '<p>'+this[editor+'_rEdit'].document.body.innerHTML+'</p>';
  }
 }
 sender.selectedIndex = 0;
 SPAW_update_toolbar(editor, true);
}

출처 http://forums.solmetra.com/viewtopic.php?f=2&t=682

반응형