tinymce_plugins_nonbreaking.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import {
  2. __commonJS,
  3. init_define_APP_INFO
  4. } from "./chunk-XY75H3MP.js";
  5. // node_modules/tinymce/plugins/nonbreaking/plugin.js
  6. var require_plugin = __commonJS({
  7. "node_modules/tinymce/plugins/nonbreaking/plugin.js"() {
  8. init_define_APP_INFO();
  9. (function() {
  10. "use strict";
  11. var global$1 = tinymce.util.Tools.resolve("tinymce.PluginManager");
  12. var getKeyboardSpaces = function(editor) {
  13. var spaces = editor.getParam("nonbreaking_force_tab", 0);
  14. if (typeof spaces === "boolean") {
  15. return spaces === true ? 3 : 0;
  16. } else {
  17. return spaces;
  18. }
  19. };
  20. var wrapNbsps = function(editor) {
  21. return editor.getParam("nonbreaking_wrap", true, "boolean");
  22. };
  23. var stringRepeat = function(string, repeats) {
  24. var str = "";
  25. for (var index = 0; index < repeats; index++) {
  26. str += string;
  27. }
  28. return str;
  29. };
  30. var isVisualCharsEnabled = function(editor) {
  31. return editor.plugins.visualchars ? editor.plugins.visualchars.isEnabled() : false;
  32. };
  33. var insertNbsp = function(editor, times) {
  34. var classes = function() {
  35. return isVisualCharsEnabled(editor) ? "mce-nbsp-wrap mce-nbsp" : "mce-nbsp-wrap";
  36. };
  37. var nbspSpan = function() {
  38. return '<span class="' + classes() + '" contenteditable="false">' + stringRepeat("&nbsp;", times) + "</span>";
  39. };
  40. var shouldWrap = wrapNbsps(editor);
  41. var html = shouldWrap || editor.plugins.visualchars ? nbspSpan() : stringRepeat("&nbsp;", times);
  42. editor.undoManager.transact(function() {
  43. return editor.insertContent(html);
  44. });
  45. };
  46. var register$1 = function(editor) {
  47. editor.addCommand("mceNonBreaking", function() {
  48. insertNbsp(editor, 1);
  49. });
  50. };
  51. var global = tinymce.util.Tools.resolve("tinymce.util.VK");
  52. var setup = function(editor) {
  53. var spaces = getKeyboardSpaces(editor);
  54. if (spaces > 0) {
  55. editor.on("keydown", function(e) {
  56. if (e.keyCode === global.TAB && !e.isDefaultPrevented()) {
  57. if (e.shiftKey) {
  58. return;
  59. }
  60. e.preventDefault();
  61. e.stopImmediatePropagation();
  62. insertNbsp(editor, spaces);
  63. }
  64. });
  65. }
  66. };
  67. var register = function(editor) {
  68. var onAction = function() {
  69. return editor.execCommand("mceNonBreaking");
  70. };
  71. editor.ui.registry.addButton("nonbreaking", {
  72. icon: "non-breaking",
  73. tooltip: "Nonbreaking space",
  74. onAction
  75. });
  76. editor.ui.registry.addMenuItem("nonbreaking", {
  77. icon: "non-breaking",
  78. text: "Nonbreaking space",
  79. onAction
  80. });
  81. };
  82. function Plugin() {
  83. global$1.add("nonbreaking", function(editor) {
  84. register$1(editor);
  85. register(editor);
  86. setup(editor);
  87. });
  88. }
  89. Plugin();
  90. })();
  91. }
  92. });
  93. // node_modules/tinymce/plugins/nonbreaking/index.js
  94. var require_nonbreaking = __commonJS({
  95. "node_modules/tinymce/plugins/nonbreaking/index.js"() {
  96. init_define_APP_INFO();
  97. require_plugin();
  98. }
  99. });
  100. // dep:tinymce_plugins_nonbreaking
  101. init_define_APP_INFO();
  102. var tinymce_plugins_nonbreaking_default = require_nonbreaking();
  103. export {
  104. tinymce_plugins_nonbreaking_default as default
  105. };
  106. //# sourceMappingURL=tinymce_plugins_nonbreaking.js.map