editor-summernote.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define("/forms/editor-summernote", ["jquery", "Site"], factory);
  4. } else if (typeof exports !== "undefined") {
  5. factory(require("jquery"), require("Site"));
  6. } else {
  7. var mod = {
  8. exports: {}
  9. };
  10. factory(global.jQuery, global.Site);
  11. global.formsEditorSummernote = mod.exports;
  12. }
  13. })(this, function (_jquery, _Site) {
  14. "use strict";
  15. _jquery = babelHelpers.interopRequireDefault(_jquery);
  16. (0, _jquery.default)(document).ready(function ($$$1) {
  17. (0, _Site.run)();
  18. }); // Example Click to edit
  19. // ---------------------
  20. window.edit = function () {
  21. (0, _jquery.default)('.click2edit').summernote({
  22. focus: true
  23. });
  24. };
  25. window.save = function () {
  26. (0, _jquery.default)('.click2edit').summernote('destroy');
  27. }; // Example Hint for words
  28. // ----------------------
  29. (function () {
  30. (0, _jquery.default)("#exampleHint2Basic").summernote({
  31. height: 100,
  32. toolbar: false,
  33. placeholder: 'type with apple, orange, watermelon and lemon',
  34. hint: {
  35. words: ['apple', 'arange', 'watermelon', 'lemon'],
  36. match: /\b(\w{1,})$/,
  37. search: function search(keyword, callback) {
  38. callback(_jquery.default.grep(this.words, function (item) {
  39. return item.indexOf(keyword) === 0;
  40. }));
  41. }
  42. }
  43. });
  44. })(); // Example Hint for words
  45. // ----------------------
  46. (function () {
  47. (0, _jquery.default)("#exampleHint2Mention").summernote({
  48. height: 100,
  49. toolbar: false,
  50. hint: {
  51. mentions: ['jayden', 'sam', 'alvin', 'david'],
  52. match: /\B@(\w*)$/,
  53. search: function search(keyword, callback) {
  54. callback(_jquery.default.grep(this.mentions, function (item) {
  55. return item.indexOf(keyword) === 0;
  56. }));
  57. },
  58. content: function content(item) {
  59. return '@' + item;
  60. }
  61. }
  62. });
  63. })();
  64. });