plugin.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Base64Image Plugin for CKEditor (http://github.com/nmmf/base64image)
  3. * Created by ALL-INKL.COM - Neue Medien M锟絥nich - 04. Feb 2014
  4. * Licensed under the terms of GPL, LGPL and MPL licenses.
  5. */
  6. CKEDITOR.plugins.add("base64image", {
  7. lang: [
  8. "af",
  9. "ar",
  10. "bg",
  11. "bn",
  12. "bs",
  13. "ca",
  14. "cs",
  15. "cy",
  16. "da",
  17. "de",
  18. "el",
  19. "en",
  20. "en-au",
  21. "en-ca",
  22. "en-gb",
  23. "eo",
  24. "es",
  25. "et",
  26. "eu",
  27. "fa",
  28. "fi",
  29. "fo",
  30. "fr",
  31. "fr-ca",
  32. "gl",
  33. "gu",
  34. "he",
  35. "hi",
  36. "hr",
  37. "hu",
  38. "id",
  39. "is",
  40. "it",
  41. "ja",
  42. "ka",
  43. "km",
  44. "ko",
  45. "ku",
  46. "lt",
  47. "lv",
  48. "mk",
  49. "mn",
  50. "ms",
  51. "nb",
  52. "nl",
  53. "no",
  54. "pl",
  55. "pt",
  56. "pt-br",
  57. "ro",
  58. "ru",
  59. "si",
  60. "sk",
  61. "sl",
  62. "sq",
  63. "sr",
  64. "sr-latn",
  65. "sv",
  66. "th",
  67. "tr",
  68. "ug",
  69. "uk",
  70. "vi",
  71. "zh",
  72. "zh-cn"
  73. ],
  74. requires: "dialog",
  75. icons: "base64image",
  76. hidpi: true,
  77. init: function(editor) {
  78. var pluginName = "base64imageDialog";
  79. editor.ui.addButton("base64image", {
  80. label: editor.lang.common.image,
  81. command: pluginName,
  82. toolbar: "insert"
  83. });
  84. CKEDITOR.dialog.add(pluginName, this.path + "dialogs/base64image.js");
  85. var allowed =
  86. "img[alt,!src]{border-style,border-width,float,height,margin,margin-bottom,margin-left,margin-right,margin-top,width}",
  87. required = "img[alt,src]";
  88. editor.addCommand(
  89. pluginName,
  90. new CKEDITOR.dialogCommand(pluginName, {
  91. allowedContent: allowed,
  92. requiredContent: required
  93. // contentTransformations: [
  94. // ["img{width}: sizeToStyle", "img[width]: sizeToAttribute"],
  95. // ["img{float}: alignmentToStyle", "img[align]: alignmentToAttribute"]
  96. // ]
  97. })
  98. );
  99. editor.on("doubleclick", function(evt) {
  100. if (
  101. evt.data.element &&
  102. !evt.data.element.isReadOnly() &&
  103. evt.data.element.getName() === "img"
  104. ) {
  105. evt.data.dialog = pluginName;
  106. editor.getSelection().selectElement(evt.data.element);
  107. }
  108. });
  109. if (editor.addMenuItem) {
  110. editor.addMenuGroup("base64imageGroup");
  111. editor.addMenuItem("base64imageItem", {
  112. label: editor.lang.common.image,
  113. icon: this.path + "icons/base64image.png",
  114. command: pluginName,
  115. group: "base64imageGroup"
  116. });
  117. }
  118. if (editor.contextMenu) {
  119. editor.contextMenu.addListener(function(element, selection) {
  120. if (element && element.getName() === "img") {
  121. editor.getSelection().selectElement(element);
  122. return { base64imageItem: CKEDITOR.TRISTATE_ON };
  123. }
  124. return null;
  125. });
  126. }
  127. }
  128. });