tinymce_plugins_save.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import {
  2. __commonJS,
  3. init_define_APP_INFO
  4. } from "./chunk-XY75H3MP.js";
  5. // node_modules/tinymce/plugins/save/plugin.js
  6. var require_plugin = __commonJS({
  7. "node_modules/tinymce/plugins/save/plugin.js"() {
  8. init_define_APP_INFO();
  9. (function() {
  10. "use strict";
  11. var global$2 = tinymce.util.Tools.resolve("tinymce.PluginManager");
  12. var global$1 = tinymce.util.Tools.resolve("tinymce.dom.DOMUtils");
  13. var global = tinymce.util.Tools.resolve("tinymce.util.Tools");
  14. var enableWhenDirty = function(editor) {
  15. return editor.getParam("save_enablewhendirty", true);
  16. };
  17. var hasOnSaveCallback = function(editor) {
  18. return !!editor.getParam("save_onsavecallback");
  19. };
  20. var hasOnCancelCallback = function(editor) {
  21. return !!editor.getParam("save_oncancelcallback");
  22. };
  23. var displayErrorMessage = function(editor, message) {
  24. editor.notificationManager.open({
  25. text: message,
  26. type: "error"
  27. });
  28. };
  29. var save = function(editor) {
  30. var formObj = global$1.DOM.getParent(editor.id, "form");
  31. if (enableWhenDirty(editor) && !editor.isDirty()) {
  32. return;
  33. }
  34. editor.save();
  35. if (hasOnSaveCallback(editor)) {
  36. editor.execCallback("save_onsavecallback", editor);
  37. editor.nodeChanged();
  38. return;
  39. }
  40. if (formObj) {
  41. editor.setDirty(false);
  42. if (!formObj.onsubmit || formObj.onsubmit()) {
  43. if (typeof formObj.submit === "function") {
  44. formObj.submit();
  45. } else {
  46. displayErrorMessage(editor, "Error: Form submit field collision.");
  47. }
  48. }
  49. editor.nodeChanged();
  50. } else {
  51. displayErrorMessage(editor, "Error: No form element found.");
  52. }
  53. };
  54. var cancel = function(editor) {
  55. var h = global.trim(editor.startContent);
  56. if (hasOnCancelCallback(editor)) {
  57. editor.execCallback("save_oncancelcallback", editor);
  58. return;
  59. }
  60. editor.resetContent(h);
  61. };
  62. var register$1 = function(editor) {
  63. editor.addCommand("mceSave", function() {
  64. save(editor);
  65. });
  66. editor.addCommand("mceCancel", function() {
  67. cancel(editor);
  68. });
  69. };
  70. var stateToggle = function(editor) {
  71. return function(api) {
  72. var handler = function() {
  73. api.setDisabled(enableWhenDirty(editor) && !editor.isDirty());
  74. };
  75. handler();
  76. editor.on("NodeChange dirty", handler);
  77. return function() {
  78. return editor.off("NodeChange dirty", handler);
  79. };
  80. };
  81. };
  82. var register = function(editor) {
  83. editor.ui.registry.addButton("save", {
  84. icon: "save",
  85. tooltip: "Save",
  86. disabled: true,
  87. onAction: function() {
  88. return editor.execCommand("mceSave");
  89. },
  90. onSetup: stateToggle(editor)
  91. });
  92. editor.ui.registry.addButton("cancel", {
  93. icon: "cancel",
  94. tooltip: "Cancel",
  95. disabled: true,
  96. onAction: function() {
  97. return editor.execCommand("mceCancel");
  98. },
  99. onSetup: stateToggle(editor)
  100. });
  101. editor.addShortcut("Meta+S", "", "mceSave");
  102. };
  103. function Plugin() {
  104. global$2.add("save", function(editor) {
  105. register(editor);
  106. register$1(editor);
  107. });
  108. }
  109. Plugin();
  110. })();
  111. }
  112. });
  113. // node_modules/tinymce/plugins/save/index.js
  114. var require_save = __commonJS({
  115. "node_modules/tinymce/plugins/save/index.js"() {
  116. init_define_APP_INFO();
  117. require_plugin();
  118. }
  119. });
  120. // dep:tinymce_plugins_save
  121. init_define_APP_INFO();
  122. var tinymce_plugins_save_default = require_save();
  123. export {
  124. tinymce_plugins_save_default as default
  125. };
  126. //# sourceMappingURL=tinymce_plugins_save.js.map