Editor.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _react = _interopRequireDefault(require("react"));
  7. var _modularityFront = _interopRequireDefault(require("modularity-front"));
  8. require("./Filter.css");
  9. var _ckeditor4React = _interopRequireDefault(require("ckeditor4-react"));
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  13. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  14. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  16. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  18. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  19. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  20. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  21. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  22. // import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
  23. _ckeditor4React.default.editorUrl = 'https://cdn.ckeditor.com/4.11.4/full-all/ckeditor.js';
  24. var Module = _modularityFront.default.Module;
  25. var Editor =
  26. /*#__PURE__*/
  27. function (_Modularity$Module) {
  28. _inherits(Editor, _Modularity$Module);
  29. function Editor(props) {
  30. var _this;
  31. _classCallCheck(this, Editor);
  32. _this = _possibleConstructorReturn(this, _getPrototypeOf(Editor).call(this, props));
  33. _this.state = _objectSpread({}, props.filter, {
  34. value: ''
  35. });
  36. return _this;
  37. }
  38. _createClass(Editor, [{
  39. key: "render",
  40. value: function render() {
  41. var _this2 = this;
  42. return _react.default.createElement("div", {
  43. className: this.className.value
  44. }, _react.default.createElement("span", null, this.Name.value), _react.default.createElement(_ckeditor4React.default // editor={ ClassicEditor }
  45. , {
  46. data: this.data.value,
  47. onInit: function onInit(editor) {// You can store the "editor" and use when it is needed.
  48. // console.log( 'Editor is ready to use!', editor );
  49. },
  50. onChange: function onChange(event, editor) {
  51. var data = event.editor.getData(); // console.log( { event, editor, data } );
  52. _this2.onChange.set(data);
  53. },
  54. onBlur: function onBlur(editor) {// console.log( 'Blur.', editor );
  55. },
  56. onFocus: function onFocus(editor) {// console.log( 'Focus.', editor );
  57. }
  58. }));
  59. }
  60. }]);
  61. return Editor;
  62. }(_modularityFront.default.Module);
  63. Editor.Inputs = {
  64. data: {
  65. type: Module.Types.Object
  66. },
  67. Name: {
  68. type: Module.Types.Text
  69. },
  70. className: {
  71. type: Module.Types.Text
  72. }
  73. };
  74. Editor.Outputs = {
  75. onChange: {}
  76. };
  77. Editor.Category = 'Nikatlas';
  78. var _default = Editor;
  79. exports.default = _default;