removeformat.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @fileoverview
  3. *
  4. */
  5. TrexConfig.addTool(
  6. "removeformat",
  7. {
  8. wysiwygonly: _TRUE,
  9. sync: _TRUE,
  10. status: _FALSE,
  11. hotKey: { // ctrl + shift + x
  12. ctrlKey: _TRUE,
  13. shiftKey: _TRUE,
  14. keyCode: 88
  15. }
  16. }
  17. );
  18. Trex.I.FontToolForRemoveformat = Trex.Mixin.create({
  19. oninitialized: function(config) {
  20. this.bindKeyboard(config.hotKey, this.handler.bind(this));
  21. },
  22. computeNewStyle: function() {
  23. return _NULL;
  24. },
  25. rangeExecutor: function(processor) {
  26. processor.execCommand(this.getQueryCommandName());
  27. }
  28. });
  29. Trex.Tool.Removeformat = Trex.Class.create({
  30. $const: {
  31. __Identity: 'removeformat'
  32. },
  33. $extend: Trex.Tool,
  34. $mixins: [Trex.I.FontTool, Trex.I.FontToolForRemoveformat],
  35. getQueryCommandName: function() {
  36. return "removeformat";
  37. },
  38. isStyleApplied: function(node) {
  39. return false;
  40. }
  41. });
  42. Trex.module('initialize removeformat without toolbar button', function(editor, toolbar, sidebar, canvas/*, config*/) {
  43. if (!$tx('tx_removeformat')) {
  44. var cfg = TrexConfig.getTool('removeformat');
  45. var el = _DOC.createElement('div');
  46. el.id = 'tx_removeformat';
  47. _DOC.body.appendChild(el);
  48. new Trex.Tool.Removeformat(editor, toolbar, cfg);
  49. }
  50. });