tinymce_plugins_tabfocus.js 4.2 KB

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