mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-08 19:42:15 +09:00
1. 텍스트를 선택하지 않을 때 indent, outdent가 되지 않던 버그 수정
2. 일부 환경에서 Enter, Shift-Enter입력시 p 태그가 많이 생기던 버그 수정(#19241534) git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7951 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
ee2f76df25
commit
a184543714
1 changed files with 142 additions and 101 deletions
|
|
@ -61,6 +61,7 @@ Xeed = xe.createApp('Xeed', {
|
|||
}
|
||||
|
||||
// Convert to wysiwyg editor
|
||||
|
||||
this.$textarea = $text;
|
||||
this.$root = $text.parent();
|
||||
this.$richedit = this.$root.find('div.edit>div.xdcs:first');
|
||||
|
|
@ -593,15 +594,15 @@ Block = xe.createPlugin('BlockCommand', {
|
|||
|
||||
if (!sel) return ret;
|
||||
|
||||
nodes = sel.collapsed?[sel.getStartNode()]:sel.getNodes();
|
||||
nodes = sel.collapsed?[sel[_sc_]]:sel.getNodes();
|
||||
|
||||
$(nodes).each(function(i,node){
|
||||
var name;
|
||||
|
||||
while(node[_pn_]) {
|
||||
while(node && node[_pn_]) {
|
||||
name = node[_nn_].toLowerCase();
|
||||
|
||||
if (/^t(able|body|foot|head|r)$/i.test(name)) {
|
||||
if (/^t(able|body|foot|head|r)$/.test(name)) {
|
||||
node = node[_pn_];
|
||||
continue;
|
||||
}
|
||||
|
|
@ -613,12 +614,29 @@ Block = xe.createPlugin('BlockCommand', {
|
|||
}
|
||||
|
||||
if (rx_root.test(node[_pn_].className || '')) {
|
||||
if (name != 'br') {
|
||||
if (node[_nt_] == 3) node = $(node).wrap('<p>')[0][_pn_];
|
||||
if (node[_nt_] == 1) node.className += ' '+_xs_;
|
||||
var nodes = [], n=node, $p;
|
||||
|
||||
ret.push(node);
|
||||
// get all non-block previous siblings
|
||||
while(n[_ps_]){
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -635,6 +653,8 @@ Block = xe.createPlugin('BlockCommand', {
|
|||
|
||||
$ret.removeClass(_xs_).each(function(){ if (!this.className) $(this).removeAttr('class') });
|
||||
|
||||
sel.select();
|
||||
|
||||
return $.makeArray($.unique(ret));
|
||||
},
|
||||
match : function(node, selector) {
|
||||
|
|
@ -697,7 +717,9 @@ Block = xe.createPlugin('BlockCommand', {
|
|||
fireChangeNode : function(sel) {
|
||||
var self = this, _sel = sel || this.oApp.getSelection();
|
||||
|
||||
setTimeout(function(){ self.cast('ON_CHANGE_NODE', [_sel[_sc_]]) }, 0);
|
||||
setTimeout(function(){
|
||||
if (_sel && _sel[_sc_]) self.cast('ON_CHANGE_NODE', [_sel[_sc_]])
|
||||
}, 0);
|
||||
},
|
||||
/**
|
||||
* @brief Quotes selection
|
||||
|
|
@ -784,7 +806,7 @@ Block = xe.createPlugin('BlockCommand', {
|
|||
this.fireChangeNode(sel);
|
||||
},
|
||||
API_EXEC_INDENT : function(sender, params) {
|
||||
var parents = this.getBlockParents();
|
||||
var sel = this.oApp.getSelection(), parents = this.getBlockParents();
|
||||
|
||||
$(parents).each(function(){
|
||||
var $this = $(this), left = parseInt($this.css('margin-left'), 10);
|
||||
|
|
@ -798,9 +820,10 @@ Block = xe.createPlugin('BlockCommand', {
|
|||
this.cast('SAVE_UNDO_POINT');
|
||||
|
||||
this.fireChangeNode();
|
||||
try { sel.select() } catch(e){};
|
||||
},
|
||||
API_EXEC_OUTDENT : function(sender, params) {
|
||||
var parents = this.getBlockParents();
|
||||
var sel = this.oApp.getSelection(), parents = this.getBlockParents();
|
||||
|
||||
$(parents).each(function(){
|
||||
var $this = $(this), left = parseInt($this.css('margin-left'), 10);
|
||||
|
|
@ -817,6 +840,7 @@ Block = xe.createPlugin('BlockCommand', {
|
|||
this.cast('SAVE_UNDO_POINT');
|
||||
|
||||
this.fireChangeNode();
|
||||
try { sel.select() } catch(e){};
|
||||
},
|
||||
/**
|
||||
* @brief
|
||||
|
|
@ -1317,14 +1341,14 @@ LineBreak = xe.createPlugin('LineBreak', {
|
|||
return false;
|
||||
},
|
||||
wrapBlock : function(sel) {
|
||||
var self = this, sc, so, eo, $node, $clone, $bookmark, last, _xb_ = '_xeed_tmp_bookmark';
|
||||
var self = this, sc, so, eo, nodes, $node, $clone, $bookmark, last, _xb_ = '_xeed_tmp_bookmark';
|
||||
|
||||
// collect all sibling
|
||||
function sibling(node, prev) {
|
||||
var s, ret = [];
|
||||
|
||||
while(s=node[prev?_ps_:_ns_]) {
|
||||
if (s[_nt_] == 3 || (s[_nt_] == 1 && !rx_block.test(s[_nn_]))) ret.push(s);
|
||||
if (s[_nt_] == 3 || (s[_nt_] == 1 && !is_block(s))) ret.push(s);
|
||||
node = s;
|
||||
}
|
||||
|
||||
|
|
@ -1350,7 +1374,13 @@ LineBreak = xe.createPlugin('LineBreak', {
|
|||
|
||||
// find block parent
|
||||
$node = $node.parentsUntil('.'+_xr_).filter(function(){ return rx_block.test(this[_nn_]) });
|
||||
$node = $node.length?$node.eq(0):$($.merge(sibling(sc,1), [sc], sibling(sc))).wrap('<p>').parent();
|
||||
if ($node.length) {
|
||||
$node = $node.eq(0);
|
||||
} else {
|
||||
nodes = $.merge(sibling(sc,1), [sc], sibling(sc));
|
||||
nodes[0][_pn_].insertBefore(($node=$('<p />')).get(0), nodes[0]);
|
||||
$node.append(nodes);
|
||||
}
|
||||
|
||||
// wrap with '<p>' in a table cell
|
||||
if ($node.is('td,th')) $node = $node.wrapInner('<p>').children(0);
|
||||
|
|
@ -2075,14 +2105,20 @@ SChar = xe.createPlugin('SChar', {
|
|||
this.$btn = $tb.find('button.sc').mousedown(function(){ self.cast('TOGGLE_SCHAR_LAYER'); return false; });
|
||||
this.$layer = this.$btn.next('div.lr')
|
||||
.mousedown(function(event){ event.stopPropagation(); })
|
||||
.find('li.li').each(function(){
|
||||
var $this = $(this), $ul = $this.find('>ul'), $li = $ul.find('li').remove(), i, c, chars;
|
||||
.find('li.li').each(function(i){
|
||||
var $this = $(this), $ul = $this.find('>ul'), $li = $ul.find('li').remove(), chars, format;
|
||||
|
||||
chars = $li.text();
|
||||
format = $('<ul>').append($li.clone(true).find('>button').text('{1}').end()).html();
|
||||
|
||||
for(i=0, c=chars.length; i < c; i++) {
|
||||
$ul.append( $li.clone(true).find('>button').text(chars.substr(i,1)).end() );
|
||||
setTimeout(function(){
|
||||
var code = [];
|
||||
for(var i=0, c=chars.length; i < c; i++) {
|
||||
code[i] = format.replace('{1}', chars.substr(i,1));
|
||||
}
|
||||
$ul.html(code.join(''));
|
||||
$ul.find('button').click(function(){ self.$text[0].value += $(this).text(); });
|
||||
}, (i+1)*100);
|
||||
})
|
||||
.end()
|
||||
.find('button.tab')
|
||||
|
|
@ -2091,9 +2127,6 @@ SChar = xe.createPlugin('SChar', {
|
|||
$(this[_pn_]).addClass('active');
|
||||
})
|
||||
.click(function(){ $(this).mousedown() })
|
||||
.end()
|
||||
.find('li>button:not(.tab)')
|
||||
.click(function(event){ self.$text[0].value += $(this).text(); })
|
||||
.end();
|
||||
|
||||
this.$text = this.$layer.find('input:text')
|
||||
|
|
@ -2148,14 +2181,17 @@ SChar = xe.createPlugin('SChar', {
|
|||
if (this.$text) this.$text.unbind();
|
||||
},
|
||||
API_SHOW_SCHAR_LAYER : function() {
|
||||
var sel;
|
||||
var sel, $layer = this.$layer;
|
||||
|
||||
if (!this.$layer || this.$layer.hasClass('open')) return;
|
||||
this.cast('HIDE_ALL_LAYER', [$layer[0]]);
|
||||
|
||||
if (!$layer || $layer.hasClass('open')) return;
|
||||
//if (!(sel=this.oApp.getSelection())) return;
|
||||
|
||||
this.sel = this.oApp.getSelection(); // save selection
|
||||
this.$btn.parent().addClass('active');
|
||||
this.$layer.addClass('open');
|
||||
|
||||
$layer.addClass('open');
|
||||
},
|
||||
API_HIDE_SCHAR_LAYER : function() {
|
||||
if (!this.$layer || !this.$layer.hasClass('open')) return;
|
||||
|
|
@ -2947,6 +2983,8 @@ Table = xe.createPlugin('Table', {
|
|||
|
||||
this.selection = this.oApp.getSelection();
|
||||
$layer.addClass('open').parent('li').addClass('active');
|
||||
|
||||
this.cast('HIDE_ALL_LAYER', [$layer[0]]);
|
||||
},
|
||||
API_HIDE_TABLE_LAYER : function(sender, params) {
|
||||
var $layer = this.$layer;
|
||||
|
|
@ -3126,7 +3164,7 @@ Clear = xe.createPlugin('Clear', {
|
|||
}
|
||||
},
|
||||
API_EXEC_CLEAR : function() {
|
||||
var sel = this.oApp.getSelection(), $div, node, par, content, after;
|
||||
var sel = this.oApp.getSelection(), node, par, content, after;
|
||||
|
||||
if (!sel || sel.collapsed) return;
|
||||
|
||||
|
|
@ -3134,7 +3172,7 @@ Clear = xe.createPlugin('Clear', {
|
|||
content = sel.extractContents();
|
||||
sel.select();
|
||||
|
||||
// TODO : get nearest parent
|
||||
// get nearest parent
|
||||
node = sel.startContainer;
|
||||
par = null;
|
||||
while(par = node[_pn_]) {
|
||||
|
|
@ -3145,8 +3183,7 @@ Clear = xe.createPlugin('Clear', {
|
|||
node = par;
|
||||
}
|
||||
|
||||
$div = $('<div />').appendTo(document).append(content);
|
||||
content = $div.remove().text();
|
||||
content = $('<div />').appendTo(document).append(content).remove().text();
|
||||
|
||||
sel.setEndAfter(par.lastChild);
|
||||
after = sel.extractContents();
|
||||
|
|
@ -3154,6 +3191,10 @@ Clear = xe.createPlugin('Clear', {
|
|||
content = document.createTextNode(content);
|
||||
par.appendChild(content);
|
||||
par.appendChild(after);
|
||||
|
||||
// save undo point
|
||||
this.cast('SAVE_UNDO_POINT');
|
||||
//this.fireChangeNode(sel);
|
||||
}
|
||||
});
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue