mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-26 14:49:56 +09:00
#19316122 선택한 라인만 제목 등으로 변경되도록 수정
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@8037 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
cf242baebb
commit
258c6132de
1 changed files with 53 additions and 53 deletions
|
|
@ -631,72 +631,70 @@ Block = xe.createPlugin('BlockCommand', {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getBlockParents : function() {
|
getBlockParents : function() {
|
||||||
var sel = this.oApp.getSelection(), nodes, ret = [], $ret, _xs_ = '_xeed_tmp_selection';
|
var sel = this.oApp.getSelection(), re = this.oApp.$richedit[0], ret = [], sc, ec, sp, ep, ca, ls, le;
|
||||||
|
|
||||||
if (!sel) return ret;
|
if (!sel) return;
|
||||||
|
|
||||||
nodes = sel.collapsed?[sel[_sc_]]:sel.getNodes();
|
function lineStopper(node){
|
||||||
|
return (is_block(node) || node[_nn_].toLowerCase() == 'br');
|
||||||
|
};
|
||||||
|
|
||||||
$(nodes).each(function(i,node){
|
function splitFrom(node, prev) {
|
||||||
var name;
|
var s = prev?_ps_:_ns_, nds, $pn, $cn, del=1;
|
||||||
|
|
||||||
while(node && node[_pn_]) {
|
if (rx_root.test(node[_pn_].className) && !is_block(node)) {
|
||||||
name = node[_nn_].toLowerCase();
|
nds = siblings(node, 1);
|
||||||
|
nds.push(node);
|
||||||
|
nds = nds.concat(siblings(node, 0));
|
||||||
|
|
||||||
if (/^t(able|body|foot|head|r)$/.test(name)) {
|
$(nds[0]).before($cn=$('<div />'));
|
||||||
node = node[_pn_];
|
$cn.append(nds);
|
||||||
continue;
|
$cn = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_block(node)) {
|
while(node !== ca && !rx_root(node[_pn_].className)) {
|
||||||
if (node[_nt_] == 1) node.className += ' '+_xs_;
|
if (node[s]) {
|
||||||
ret.push(node);
|
if (del) del = 0;
|
||||||
break;
|
nds = siblings(node, prev, function(){ return 0 });
|
||||||
}
|
|
||||||
|
|
||||||
if (rx_root.test(node[_pn_].className || '')) {
|
$pn = $(node[_pn_]);
|
||||||
var nodes = [], n=node, $p;
|
$cn = $pn.clone().empty();
|
||||||
|
|
||||||
// get all non-block previous siblings
|
$pn[prev?'before':'after']($cn);
|
||||||
while(n[_ps_]){
|
$cn.append(nds);
|
||||||
if (is_block(n[_ps_])) break;
|
|
||||||
nodes.push(n[_ps_]);
|
|
||||||
n = n[_ps_];
|
|
||||||
}
|
|
||||||
nodes.reverse();
|
|
||||||
|
|
||||||
// current node
|
|
||||||
nodes.push(n=node);
|
|
||||||
|
|
||||||
// get all non-block next siblings
|
|
||||||
while(n[_ns_]) {
|
|
||||||
if (is_block(n[_ns_])) break;
|
|
||||||
nodes.push(n[_ns_]);
|
|
||||||
n = n[_ns_];
|
|
||||||
}
|
|
||||||
|
|
||||||
$p = $('<p />').addClass(_xs_);
|
|
||||||
node[_pn_].insertBefore($p[0], nodes[0]);
|
|
||||||
ret.push($p.append(nodes).get(0));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node[_pn_];
|
node = node[_pn_];
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
$ret = $(ret);
|
if ($cn && del) $cn.remove();
|
||||||
|
};
|
||||||
|
|
||||||
ret = $ret.filter(function(){
|
ca = get_block_parent(sel[_ca_]);
|
||||||
var $this = $(this);
|
sc = sel[_sc_]; sp = get_block_parent(sc); sc = get_child(sc, sp);
|
||||||
return !$this.is('.'+_xr_) && !$this.parentsUntil('.'+_xr_).filter('.'+_xs_).length;
|
ec = sel[_ec_]; ep = get_block_parent(ec); ec = get_child(ec, ep);
|
||||||
});
|
|
||||||
|
|
||||||
$ret.removeClass(_xs_).each(function(){ if (!this.className) $(this).removeAttr('class') });
|
// find line start
|
||||||
|
ls = siblings(sc, 1, lineStopper).shift() || sc;
|
||||||
|
if (ls[_ps_] && ls[_ps_][_nn_].toLowerCase() == 'br') $(ls[_ps_]).remove();
|
||||||
|
splitFrom(ls, 1);
|
||||||
|
|
||||||
sel.select();
|
// find line end
|
||||||
|
le = siblings(ec, 0, lineStopper).pop() || ec;
|
||||||
|
if (le[_ns_] && le[_ns_][_nn_].toLowerCase() == 'br') $(le[_ns_]).remove();
|
||||||
|
splitFrom(le, 0);
|
||||||
|
|
||||||
|
sc = get_block_parent(get_child(ls, ca));
|
||||||
|
ec = get_block_parent(get_child(le, ca));
|
||||||
|
|
||||||
|
ret = [sc];
|
||||||
|
|
||||||
|
if (sc !== ec) {
|
||||||
|
ret = ret.concat(siblings(sc, 0, function(nd){ return (nd !== ec) }));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
return $.makeArray($.unique(ret));
|
|
||||||
},
|
},
|
||||||
match : function(node, selector) {
|
match : function(node, selector) {
|
||||||
var $node = $(node);
|
var $node = $(node);
|
||||||
|
|
@ -5102,11 +5100,13 @@ function get_valid_parent(par, childName) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// collect all inline sibling
|
// collect all inline sibling
|
||||||
function siblings(node, prev) {
|
function siblings(node, prev, stopper) {
|
||||||
var s, ret = [];
|
var s, ret = [];
|
||||||
|
|
||||||
|
if (!stopper) stopper = is_block;
|
||||||
|
|
||||||
while(s=node[prev?_ps_:_ns_]) {
|
while(s=node[prev?_ps_:_ns_]) {
|
||||||
if (is_block(s)) break;
|
if (stopper(s)) break;
|
||||||
if (s[_nt_] == 3 || s[_nt_] == 1) ret.push(s);
|
if (s[_nt_] == 3 || s[_nt_] == 1) ret.push(s);
|
||||||
node = s;
|
node = s;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue