test-plugin.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*!
  2. * Test plugin for Editor.md
  3. *
  4. * @file test-plugin.js
  5. * @author pandao
  6. * @version 1.2.0
  7. * @updateTime 2015-03-07
  8. * {@link https://github.com/pandao/editor.md}
  9. * @license MIT
  10. */
  11. (function() {
  12. var factory = function (exports) {
  13. var $ = jQuery; // if using module loader(Require.js/Sea.js).
  14. exports.testPlugin = function(){
  15. alert("testPlugin");
  16. };
  17. exports.fn.testPluginMethodA = function() {
  18. /*
  19. var _this = this; // this == the current instance object of Editor.md
  20. var lang = _this.lang;
  21. var settings = _this.settings;
  22. var editor = this.editor;
  23. var cursor = cm.getCursor();
  24. var selection = cm.getSelection();
  25. var classPrefix = this.classPrefix;
  26. cm.focus();
  27. */
  28. //....
  29. alert("testPluginMethodA");
  30. };
  31. };
  32. // CommonJS/Node.js
  33. if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
  34. {
  35. module.exports = factory;
  36. }
  37. else if (typeof define === "function") // AMD/CMD/Sea.js
  38. {
  39. if (define.amd) { // for Require.js
  40. define(["editormd"], function(editormd) {
  41. factory(editormd);
  42. });
  43. } else { // for Sea.js
  44. define(function(require) {
  45. var editormd = require("./../../editormd");
  46. factory(editormd);
  47. });
  48. }
  49. }
  50. else
  51. {
  52. factory(window.editormd);
  53. }
  54. })();