tinymce_plugins_code.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import {
  2. __commonJS
  3. } from "./chunk-2LSFTFF7.js";
  4. // node_modules/.pnpm/tinymce@5.10.7/node_modules/tinymce/plugins/code/plugin.js
  5. var require_plugin = __commonJS({
  6. "node_modules/.pnpm/tinymce@5.10.7/node_modules/tinymce/plugins/code/plugin.js"() {
  7. (function() {
  8. "use strict";
  9. var global = tinymce.util.Tools.resolve("tinymce.PluginManager");
  10. var setContent = function(editor, html) {
  11. editor.focus();
  12. editor.undoManager.transact(function() {
  13. editor.setContent(html);
  14. });
  15. editor.selection.setCursorLocation();
  16. editor.nodeChanged();
  17. };
  18. var getContent = function(editor) {
  19. return editor.getContent({ source_view: true });
  20. };
  21. var open = function(editor) {
  22. var editorContent = getContent(editor);
  23. editor.windowManager.open({
  24. title: "Source Code",
  25. size: "large",
  26. body: {
  27. type: "panel",
  28. items: [{
  29. type: "textarea",
  30. name: "code"
  31. }]
  32. },
  33. buttons: [
  34. {
  35. type: "cancel",
  36. name: "cancel",
  37. text: "Cancel"
  38. },
  39. {
  40. type: "submit",
  41. name: "save",
  42. text: "Save",
  43. primary: true
  44. }
  45. ],
  46. initialData: { code: editorContent },
  47. onSubmit: function(api) {
  48. setContent(editor, api.getData().code);
  49. api.close();
  50. }
  51. });
  52. };
  53. var register$1 = function(editor) {
  54. editor.addCommand("mceCodeEditor", function() {
  55. open(editor);
  56. });
  57. };
  58. var register = function(editor) {
  59. var onAction = function() {
  60. return editor.execCommand("mceCodeEditor");
  61. };
  62. editor.ui.registry.addButton("code", {
  63. icon: "sourcecode",
  64. tooltip: "Source code",
  65. onAction
  66. });
  67. editor.ui.registry.addMenuItem("code", {
  68. icon: "sourcecode",
  69. text: "Source code",
  70. onAction
  71. });
  72. };
  73. function Plugin() {
  74. global.add("code", function(editor) {
  75. register$1(editor);
  76. register(editor);
  77. return {};
  78. });
  79. }
  80. Plugin();
  81. })();
  82. }
  83. });
  84. // node_modules/.pnpm/tinymce@5.10.7/node_modules/tinymce/plugins/code/index.js
  85. require_plugin();
  86. //# sourceMappingURL=tinymce_plugins_code.js.map