tinymce_plugins_tabfocus.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import {
  2. __commonJS,
  3. init_define_APP_INFO
  4. } from "./chunk-XY75H3MP.js";
  5. // node_modules/tinymce/plugins/tabfocus/plugin.js
  6. var require_plugin = __commonJS({
  7. "node_modules/tinymce/plugins/tabfocus/plugin.js"() {
  8. init_define_APP_INFO();
  9. (function() {
  10. "use strict";
  11. var global$6 = tinymce.util.Tools.resolve("tinymce.PluginManager");
  12. var global$5 = tinymce.util.Tools.resolve("tinymce.dom.DOMUtils");
  13. var global$4 = tinymce.util.Tools.resolve("tinymce.EditorManager");
  14. var global$3 = tinymce.util.Tools.resolve("tinymce.Env");
  15. var global$2 = tinymce.util.Tools.resolve("tinymce.util.Delay");
  16. var global$1 = tinymce.util.Tools.resolve("tinymce.util.Tools");
  17. var global = tinymce.util.Tools.resolve("tinymce.util.VK");
  18. var getTabFocusElements = function(editor) {
  19. return editor.getParam("tabfocus_elements", ":prev,:next");
  20. };
  21. var getTabFocus = function(editor) {
  22. return editor.getParam("tab_focus", getTabFocusElements(editor));
  23. };
  24. var DOM = global$5.DOM;
  25. var tabCancel = function(e) {
  26. if (e.keyCode === global.TAB && !e.ctrlKey && !e.altKey && !e.metaKey) {
  27. e.preventDefault();
  28. }
  29. };
  30. var setup = function(editor) {
  31. var tabHandler = function(e) {
  32. var x;
  33. if (e.keyCode !== global.TAB || e.ctrlKey || e.altKey || e.metaKey || e.isDefaultPrevented()) {
  34. return;
  35. }
  36. var find = function(direction) {
  37. var el2 = DOM.select(":input:enabled,*[tabindex]:not(iframe)");
  38. var canSelectRecursive = function(e2) {
  39. var castElem = e2;
  40. return e2.nodeName === "BODY" || castElem.type !== "hidden" && castElem.style.display !== "none" && castElem.style.visibility !== "hidden" && canSelectRecursive(e2.parentNode);
  41. };
  42. var canSelect = function(el3) {
  43. return /INPUT|TEXTAREA|BUTTON/.test(el3.tagName) && global$4.get(e.id) && el3.tabIndex !== -1 && canSelectRecursive(el3);
  44. };
  45. global$1.each(el2, function(e2, i2) {
  46. if (e2.id === editor.id) {
  47. x = i2;
  48. return false;
  49. }
  50. });
  51. if (direction > 0) {
  52. for (var i = x + 1; i < el2.length; i++) {
  53. if (canSelect(el2[i])) {
  54. return el2[i];
  55. }
  56. }
  57. } else {
  58. for (var i = x - 1; i >= 0; i--) {
  59. if (canSelect(el2[i])) {
  60. return el2[i];
  61. }
  62. }
  63. }
  64. return null;
  65. };
  66. var v = global$1.explode(getTabFocus(editor));
  67. if (v.length === 1) {
  68. v[1] = v[0];
  69. v[0] = ":prev";
  70. }
  71. var el;
  72. if (e.shiftKey) {
  73. if (v[0] === ":prev") {
  74. el = find(-1);
  75. } else {
  76. el = DOM.get(v[0]);
  77. }
  78. } else {
  79. if (v[1] === ":next") {
  80. el = find(1);
  81. } else {
  82. el = DOM.get(v[1]);
  83. }
  84. }
  85. if (el) {
  86. var focusEditor = global$4.get(el.id || el.name);
  87. if (el.id && focusEditor) {
  88. focusEditor.focus();
  89. } else {
  90. global$2.setTimeout(function() {
  91. if (!global$3.webkit) {
  92. window.focus();
  93. }
  94. el.focus();
  95. }, 10);
  96. }
  97. e.preventDefault();
  98. }
  99. };
  100. editor.on("init", function() {
  101. if (editor.inline) {
  102. DOM.setAttrib(editor.getBody(), "tabIndex", null);
  103. }
  104. editor.on("keyup", tabCancel);
  105. if (global$3.gecko) {
  106. editor.on("keypress keydown", tabHandler);
  107. } else {
  108. editor.on("keydown", tabHandler);
  109. }
  110. });
  111. };
  112. function Plugin() {
  113. global$6.add("tabfocus", function(editor) {
  114. setup(editor);
  115. });
  116. }
  117. Plugin();
  118. })();
  119. }
  120. });
  121. // node_modules/tinymce/plugins/tabfocus/index.js
  122. var require_tabfocus = __commonJS({
  123. "node_modules/tinymce/plugins/tabfocus/index.js"() {
  124. init_define_APP_INFO();
  125. require_plugin();
  126. }
  127. });
  128. // dep:tinymce_plugins_tabfocus
  129. init_define_APP_INFO();
  130. var tinymce_plugins_tabfocus_default = require_tabfocus();
  131. export {
  132. tinymce_plugins_tabfocus_default as default
  133. };
  134. //# sourceMappingURL=tinymce_plugins_tabfocus.js.map