plugin.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * Copyright (c) Tiny Technologies, Inc. All rights reserved.
  3. * Licensed under the LGPL or a commercial license.
  4. * For LGPL see License.txt in the project root for license information.
  5. * For commercial licenses see https://www.tiny.cloud/
  6. *
  7. * Version: 5.2.0 (2020-02-13)
  8. */
  9. (function () {
  10. 'use strict';
  11. var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
  12. var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
  13. var register = function (editor) {
  14. editor.addCommand('mcePrint', function () {
  15. if (global$1.browser.isIE()) {
  16. editor.getDoc().execCommand('print', false, null);
  17. } else {
  18. editor.getWin().print();
  19. }
  20. });
  21. };
  22. var Commands = { register: register };
  23. var register$1 = function (editor) {
  24. editor.ui.registry.addButton('print', {
  25. icon: 'print',
  26. tooltip: 'Print',
  27. onAction: function () {
  28. return editor.execCommand('mcePrint');
  29. }
  30. });
  31. editor.ui.registry.addMenuItem('print', {
  32. text: 'Print...',
  33. icon: 'print',
  34. onAction: function () {
  35. return editor.execCommand('mcePrint');
  36. }
  37. });
  38. };
  39. var Buttons = { register: register$1 };
  40. function Plugin () {
  41. global.add('print', function (editor) {
  42. Commands.register(editor);
  43. Buttons.register(editor);
  44. editor.addShortcut('Meta+P', '', 'mcePrint');
  45. });
  46. }
  47. Plugin();
  48. }());