processor_trident.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. Trex.I.Processor.Trident = {
  2. /**
  3. * Paragraph 를 채운다.
  4. * @private
  5. * @param {Node} node - paragraph 노드
  6. */
  7. stuffNode: function(node) {
  8. if($tom.getLength(node) == 0) {
  9. node.innerHTML = ' ';
  10. }
  11. return node;
  12. },
  13. /**
  14. * @private
  15. * @memberOf Trex.Canvas.ProcessorP
  16. * Trident에서 newlinepolicy가 p일 경우 Enter Key 이벤트가 발생하면 실행한다.
  17. */
  18. controlEnterByParagraph: function() {
  19. var _bNode = this.findNode('div');
  20. var _dvNode;
  21. if (!_bNode) {
  22. throw $propagate;
  23. }
  24. var _pNode = this.findNode('%paragraph');
  25. if ($tom.kindOf(_pNode, 'p')) {
  26. if($tom.first(_bNode, 'p') == _pNode) {
  27. this.execWithMarker(function(marker) {
  28. _dvNode = $tom.divideParagraph(marker.endMarker);
  29. });
  30. this.stuffNode(_pNode);
  31. this.stuffNode(_dvNode);
  32. this.moveCaretTo(_dvNode);
  33. } else {
  34. throw $propagate;
  35. }
  36. } else if($tom.kindOf(_pNode, 'li,td,th,dd,dt')) {
  37. throw $propagate;
  38. } else {
  39. _dvNode = this.newParagraph('p');
  40. this.execWithMarker(function(marker) {
  41. $tom.insertNext(_dvNode, marker.endMarker);
  42. });
  43. this.moveCaretTo(_dvNode);
  44. }
  45. }
  46. };
  47. Trex.module("delete image element @when backspace key event fires",
  48. function(editor, toolbar, sidebar, canvas) {
  49. if ($tx.msie_nonstd) {
  50. canvas.observeKey({
  51. ctrlKey: _FALSE,
  52. altKey: _FALSE,
  53. shiftKey: _FALSE,
  54. keyCode: Trex.__KEY.BACKSPACE
  55. }, function() {
  56. var _processor = canvas.getProcessor();
  57. if (_processor.hasControl() && _processor.getControl()) {
  58. try {
  59. var _node = _processor.getControl();
  60. $tom.remove(_node);
  61. } catch (e) { }
  62. throw $stop;
  63. }
  64. throw $propagate;
  65. });
  66. }
  67. }
  68. );
  69. Trex.module("delete table element @when backspace key event fires",
  70. function(editor, toolbar, sidebar, canvas) {
  71. if ($tx.msie_nonstd) {
  72. var _oldRangeLeftOffset;
  73. canvas.observeKey({
  74. ctrlKey: _FALSE,
  75. altKey: _FALSE,
  76. shiftKey: _FALSE,
  77. keyCode: Trex.__KEY.BACKSPACE
  78. }, function() {
  79. var _processor = canvas.getProcessor();
  80. var _rng = _processor.getRange();
  81. try{
  82. if(_oldRangeLeftOffset == _rng.boundingLeft){
  83. var _el = $tom.previous(_processor.getNode());
  84. if($tom.kindOf(_el, "table")){
  85. $tom.remove(_el);
  86. }
  87. }
  88. }catch(e){ }
  89. _oldRangeLeftOffset = _rng.boundingLeft;
  90. throw $propagate;
  91. });
  92. }
  93. }
  94. );
  95. /*-------------------------------------------------------*/
  96. Object.extend(Trex.I.Processor.Trident, {
  97. restoreRange: function() { //TODO: rename
  98. if (!this.isRangeInsideWysiwyg && this.lastRange) {
  99. try {
  100. this.lastRange.select();
  101. } catch (e) {
  102. var _sel = this.getSel();
  103. var _type = _sel.type.toLowerCase();
  104. if (_type === "control") {
  105. _sel.empty();
  106. var _rng = _sel.createRange();
  107. _rng.collapse(_FALSE);
  108. _rng.select();
  109. }
  110. } finally {
  111. this.lastRange = _NULL;
  112. }
  113. }
  114. }
  115. });