@comet/admin-rte 8.17.1 → 9.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/lib/core/BlockElement.js +11 -15
  2. package/lib/core/Controls/BlockTypesControls.js +17 -24
  3. package/lib/core/Controls/ControlButton.js +11 -18
  4. package/lib/core/Controls/Controls.js +14 -21
  5. package/lib/core/Controls/CustomControls.js +5 -12
  6. package/lib/core/Controls/FeaturesButtonGroup.d.ts +1 -1
  7. package/lib/core/Controls/FeaturesButtonGroup.d.ts.map +1 -1
  8. package/lib/core/Controls/FeaturesButtonGroup.js +35 -41
  9. package/lib/core/Controls/HistoryContols.js +6 -13
  10. package/lib/core/Controls/InlineStyleTypeControls.js +6 -13
  11. package/lib/core/Controls/LinkControls.js +19 -26
  12. package/lib/core/Controls/ListsControls.js +6 -13
  13. package/lib/core/Controls/ListsIndentControls.js +6 -13
  14. package/lib/core/Controls/SpecialCharactersControls.js +7 -14
  15. package/lib/core/Controls/Toolbar/Toolbar.d.ts +1 -0
  16. package/lib/core/Controls/Toolbar/Toolbar.d.ts.map +1 -1
  17. package/lib/core/Controls/Toolbar/Toolbar.js +9 -15
  18. package/lib/core/Controls/Toolbar/Toolbar.styles.d.ts +2 -2
  19. package/lib/core/Controls/Toolbar/Toolbar.styles.js +7 -14
  20. package/lib/core/Controls/TranslationControls.js +8 -15
  21. package/lib/core/Controls/useBlockTypes.d.ts +1 -1
  22. package/lib/core/Controls/useBlockTypes.d.ts.map +1 -1
  23. package/lib/core/Controls/useBlockTypes.js +16 -23
  24. package/lib/core/Controls/useHistory.js +16 -22
  25. package/lib/core/Controls/useInlineStyleType.d.ts +1 -1
  26. package/lib/core/Controls/useInlineStyleType.d.ts.map +1 -1
  27. package/lib/core/Controls/useInlineStyleType.js +30 -37
  28. package/lib/core/Controls/useListIndent.js +23 -29
  29. package/lib/core/Rte.js +47 -54
  30. package/lib/core/RteReadOnly.js +18 -25
  31. package/lib/core/defaultBlocktypeMap.js +30 -38
  32. package/lib/core/extension/Link/Decorator.js +4 -11
  33. package/lib/core/extension/Link/EditorComponent.js +3 -9
  34. package/lib/core/extension/Link/ToolbarButton.js +50 -55
  35. package/lib/core/extension/LinksRemove/ToolbarButton.js +8 -14
  36. package/lib/core/extension/NonBreakingSpace/Decorator.js +3 -10
  37. package/lib/core/extension/NonBreakingSpace/EditorComponent.js +8 -14
  38. package/lib/core/extension/NonBreakingSpace/ToolbarButton.js +15 -23
  39. package/lib/core/extension/SoftHyphen/Decorator.js +3 -9
  40. package/lib/core/extension/SoftHyphen/EditorComponent.js +7 -13
  41. package/lib/core/extension/SoftHyphen/ToolbarButton.js +14 -22
  42. package/lib/core/filterEditor/composeFilterEditorFns.js +1 -7
  43. package/lib/core/filterEditor/default.js +9 -16
  44. package/lib/core/filterEditor/manageStandardBlockType.js +3 -9
  45. package/lib/core/filterEditor/removeBlocksExceedingBlockLimit.js +4 -10
  46. package/lib/core/filterEditor/removeUnsupportedBlockTypes.js +3 -10
  47. package/lib/core/filterEditor/removeUnsupportedEntities.js +3 -10
  48. package/lib/core/filterEditor/removeUnsupportedInlineStyles.js +3 -10
  49. package/lib/core/filterEditor/removeUnsupportedListLevels.js +3 -9
  50. package/lib/core/filterEditor/utils/changeBlockType.js +3 -9
  51. package/lib/core/filterEditor/utils/manipulateEntityData.js +3 -9
  52. package/lib/core/filterEditor/utils/removeEntities.js +4 -10
  53. package/lib/core/filterEditor/utils/removeInlineStyles.js +4 -10
  54. package/lib/core/makeRteApi.js +19 -26
  55. package/lib/core/translation/EditorStateTranslationDialog.js +8 -15
  56. package/lib/core/translation/ToolbarButton.js +22 -28
  57. package/lib/core/translation/htmlToState.js +7 -13
  58. package/lib/core/translation/stateToHtml.js +5 -12
  59. package/lib/core/types.d.ts +2 -2
  60. package/lib/core/types.d.ts.map +1 -1
  61. package/lib/core/types.js +1 -5
  62. package/lib/core/utils/createBlockRenderMap.js +4 -12
  63. package/lib/core/utils/findEntityDataInCurrentSelection.js +3 -9
  64. package/lib/core/utils/findEntityInCurrentSelection.js +7 -13
  65. package/lib/core/utils/findTextInCurrentSelection.js +3 -9
  66. package/lib/core/utils/getCurrentBlock.js +1 -7
  67. package/lib/core/utils/getRteTheme.js +13 -19
  68. package/lib/core/utils/pasteAndFilterText.js +7 -13
  69. package/lib/core/utils/rangesIntersect.js +1 -7
  70. package/lib/core/utils/selectionIsInOneBlock.js +1 -7
  71. package/lib/field/createFinalFormRte.js +10 -17
  72. package/lib/field/createRteField.js +8 -15
  73. package/lib/index.js +28 -202
  74. package/lib/useDebounce.js +5 -10
  75. package/lib/usePrevious.js +4 -9
  76. package/lib/utils/requiredValidator.js +6 -12
  77. package/package.json +18 -14
@@ -1,18 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _admin = require("@comet/admin");
8
- var _adminIcons = require("@comet/admin-icons");
9
- var _react = require("react");
10
- var _reactIntl = require("react-intl");
11
- var _ControlButton = require("../Controls/ControlButton");
12
- var _EditorStateTranslationDialog = require("./EditorStateTranslationDialog");
13
- var _htmlToState = require("./htmlToState");
14
- var _stateToHtml2 = require("./stateToHtml");
15
- var _jsxRuntime = require("react/jsx-runtime");
16
1
  function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
17
2
  function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
18
3
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
@@ -23,16 +8,25 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
23
8
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
24
9
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
25
10
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
11
+ import { Tooltip, useContentTranslationService } from "@comet/admin";
12
+ import { Translate } from "@comet/admin-icons";
13
+ import { useState } from "react";
14
+ import { FormattedMessage } from "react-intl";
15
+ import { ControlButton } from "../Controls/ControlButton";
16
+ import { EditorStateTranslationDialog } from "./EditorStateTranslationDialog";
17
+ import { htmlToState } from "./htmlToState";
18
+ import { stateToHtml } from "./stateToHtml";
19
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
26
20
  function ToolbarButton(_ref) {
27
21
  var editorState = _ref.editorState,
28
22
  setEditorState = _ref.setEditorState,
29
23
  options = _ref.options;
30
- var translationContext = (0, _admin.useContentTranslationService)();
31
- var _useState = (0, _react.useState)(false),
24
+ var translationContext = useContentTranslationService();
25
+ var _useState = useState(false),
32
26
  _useState2 = _slicedToArray(_useState, 2),
33
27
  open = _useState2[0],
34
28
  setOpen = _useState2[1];
35
- var _useState3 = (0, _react.useState)(undefined),
29
+ var _useState3 = useState(undefined),
36
30
  _useState4 = _slicedToArray(_useState3, 2),
37
31
  pendingTranslation = _useState4[0],
38
32
  setPendingTranslation = _useState4[1];
@@ -52,7 +46,7 @@ function ToolbarButton(_ref) {
52
46
  return _context.a(2);
53
47
  case 1:
54
48
  event.preventDefault();
55
- _stateToHtml = (0, _stateToHtml2.stateToHtml)({
49
+ _stateToHtml = stateToHtml({
56
50
  editorState: editorState,
57
51
  options: options
58
52
  }), html = _stateToHtml.html, entities = _stateToHtml.entities;
@@ -60,7 +54,7 @@ function ToolbarButton(_ref) {
60
54
  return translationContext.translate(html);
61
55
  case 2:
62
56
  translation = _context.v;
63
- translatedEditorState = (0, _htmlToState.htmlToState)({
57
+ translatedEditorState = htmlToState({
64
58
  html: translation,
65
59
  entities: entities
66
60
  });
@@ -77,20 +71,20 @@ function ToolbarButton(_ref) {
77
71
  }));
78
72
  return _handleClick.apply(this, arguments);
79
73
  }
80
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
81
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_admin.Tooltip, {
82
- title: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
74
+ return /*#__PURE__*/_jsxs(_Fragment, {
75
+ children: [/*#__PURE__*/_jsx(Tooltip, {
76
+ title: /*#__PURE__*/_jsx(FormattedMessage, {
83
77
  id: "comet.rte.translation.buttonTooltip",
84
78
  defaultMessage: "Translate"
85
79
  }),
86
80
  placement: "top",
87
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
88
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ControlButton.ControlButton, {
89
- icon: _adminIcons.Translate,
81
+ children: /*#__PURE__*/_jsx("span", {
82
+ children: /*#__PURE__*/_jsx(ControlButton, {
83
+ icon: Translate,
90
84
  onButtonClick: handleClick
91
85
  })
92
86
  })
93
- }), open && pendingTranslation && /*#__PURE__*/(0, _jsxRuntime.jsx)(_EditorStateTranslationDialog.EditorStateTranslationDialog, {
87
+ }), open && pendingTranslation && /*#__PURE__*/_jsx(EditorStateTranslationDialog, {
94
88
  open: open,
95
89
  onClose: function onClose() {
96
90
  return setOpen(false);
@@ -101,4 +95,4 @@ function ToolbarButton(_ref) {
101
95
  })]
102
96
  });
103
97
  }
104
- var _default = exports["default"] = ToolbarButton;
98
+ export default ToolbarButton;
@@ -1,15 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.htmlToState = htmlToState;
7
- var _draftJs = require("draft-js");
8
- var _draftJsImportHtml = require("draft-js-import-html");
9
- function htmlToState(_ref) {
1
+ import { convertFromRaw, convertToRaw, EditorState } from "draft-js";
2
+ import { stateFromHTML } from "draft-js-import-html";
3
+ export function htmlToState(_ref) {
10
4
  var html = _ref.html,
11
5
  entities = _ref.entities;
12
- var translatedContentState = (0, _draftJsImportHtml.stateFromHTML)(html, {
6
+ var translatedContentState = stateFromHTML(html, {
13
7
  customBlockFn: function customBlockFn(element) {
14
8
  if (element.className) {
15
9
  return {
@@ -36,7 +30,7 @@ function htmlToState(_ref) {
36
30
  }
37
31
  }
38
32
  });
39
- var _convertToRaw = (0, _draftJs.convertToRaw)(translatedContentState),
33
+ var _convertToRaw = convertToRaw(translatedContentState),
40
34
  entityMap = _convertToRaw.entityMap,
41
35
  blocks = _convertToRaw.blocks;
42
36
  var _loop = function _loop() {
@@ -51,9 +45,9 @@ function htmlToState(_ref) {
51
45
  for (var _i = 0, _Object$keys = Object.keys(entityMap); _i < _Object$keys.length; _i++) {
52
46
  _loop();
53
47
  }
54
- var translatedContentStateWithLinkData = (0, _draftJs.convertFromRaw)({
48
+ var translatedContentStateWithLinkData = convertFromRaw({
55
49
  entityMap: entityMap,
56
50
  blocks: blocks
57
51
  });
58
- return _draftJs.EditorState.createWithContent(translatedContentStateWithLinkData);
52
+ return EditorState.createWithContent(translatedContentStateWithLinkData);
59
53
  }
@@ -1,13 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.stateToHtml = stateToHtml;
7
- var _draftJsExportHtml = require("draft-js-export-html");
8
- var _defaultBlocktypeMap = _interopRequireDefault(require("../defaultBlocktypeMap"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
- function stateToHtml(_ref) {
1
+ import { stateToHTML } from "draft-js-export-html";
2
+ import defaultBlocktypeMap from "../defaultBlocktypeMap";
3
+ export function stateToHtml(_ref) {
11
4
  var editorState = _ref.editorState,
12
5
  options = _ref.options;
13
6
  var contentState = editorState.getCurrentContent();
@@ -29,11 +22,11 @@ function stateToHtml(_ref) {
29
22
  };
30
23
  });
31
24
  var entities = [];
32
- var html = (0, _draftJsExportHtml.stateToHTML)(contentState, {
25
+ var html = stateToHTML(contentState, {
33
26
  inlineStyles: inlineStyles,
34
27
  blockStyleFn: function blockStyleFn(block) {
35
28
  var type = block.getType();
36
- if (!Object.keys(_defaultBlocktypeMap["default"]).includes(type)) {
29
+ if (!Object.keys(defaultBlocktypeMap).includes(type)) {
37
30
  return {
38
31
  attributes: {
39
32
  "class": type
@@ -1,6 +1,6 @@
1
1
  import { type SvgIconProps } from "@mui/material/SvgIcon";
2
2
  import { type DraftInlineStyleType, type Editor, type EditorState } from "draft-js";
3
- import { type ComponentType, type CSSProperties, type ForwardRefExoticComponent, type MouseEvent, type ReactNode, type RefAttributes, type RefObject } from "react";
3
+ import { type ComponentType, type CSSProperties, type ForwardRefExoticComponent, type JSX, type MouseEvent, type ReactNode, type RefAttributes, type RefObject } from "react";
4
4
  import { type IRteOptions, type SupportedThings } from "./Rte";
5
5
  interface DraftBlockRenderConfig {
6
6
  element: string | ComponentType;
@@ -34,7 +34,7 @@ export interface IControlProps {
34
34
  editorState: EditorState;
35
35
  setEditorState: (editorState: EditorState) => void;
36
36
  options: IRteOptions;
37
- editorRef: RefObject<Editor>;
37
+ editorRef: RefObject<Editor | null>;
38
38
  disabled?: boolean;
39
39
  }
40
40
  export type ToolbarButtonComponent = (props: IControlProps) => JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AACpF,OAAO,EACH,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,yBAAyB,EAC9B,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,OAAO,CAAC;AAG/D,UAAU,sBAAsB;IAC5B,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC;IAChC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAgB;IAC7B,YAAY,CAAC,EAAE,sBAAsB,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAC;IAC9B,IA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AC,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,GAAG,CAAC,OAAO,CAAC;AAE3E,MAAM,MAAM,mBAAmB,GAAG,CAAC,SAAS,EAAE,WAAW,KAAK,WAAW,CAAC;AAE1E;;GAEG;AACH,UAAU,2BAA2B;IACjC,YAAY,EAAE,sBAAsB,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC3C,CAAC,GAAG,EAAE,MAAM,GAAG,2BAA2B,CAAC;CAC9C;AAED,MAAM,WAAW,kBAAkB;IAC/B,CAAC,IAAI,EAAE,MAAM,GAAG;QACZ,KAAK,EAAE,SAAS,CAAC;QACjB,IAAI,CAAC,EAAE,yBAAyB,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;QAC3F,WAAW,CAAC,EAAE,SAAS,CAAC;QACxB,KAAK,EAAE,aAAa,CAAC;KACxB,CAAC;CACL"}
package/lib/core/types.js CHANGED
@@ -1,5 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
@@ -1,20 +1,12 @@
1
- "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports["default"] = createBlockRenderMap;
8
- var _draftJs = require("draft-js");
9
- var Immutable = _interopRequireWildcard(require("immutable"));
10
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
11
1
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
12
2
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
3
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
14
4
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
15
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
6
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
17
- function createBlockRenderMap(_ref) {
7
+ import { DefaultDraftBlockRenderMap } from "draft-js";
8
+ import * as Immutable from "immutable";
9
+ export default function createBlockRenderMap(_ref) {
18
10
  var blocktypeMap = _ref.blocktypeMap;
19
11
  var customBlockRenderMapObject = Object.entries(blocktypeMap).reduce(function (a, _ref2) {
20
12
  var _ref3 = _slicedToArray(_ref2, 2),
@@ -26,5 +18,5 @@ function createBlockRenderMap(_ref) {
26
18
  return a;
27
19
  }, {});
28
20
  var customBlockRenderMap = Immutable.Map(customBlockRenderMapObject);
29
- return customBlockRenderMap ? _draftJs.DefaultDraftBlockRenderMap.merge(customBlockRenderMap) : _draftJs.DefaultDraftBlockRenderMap;
21
+ return customBlockRenderMap ? DefaultDraftBlockRenderMap.merge(customBlockRenderMap) : DefaultDraftBlockRenderMap;
30
22
  }
@@ -1,14 +1,8 @@
1
- "use strict";
1
+ import findEntityInCurrentSelection from "./findEntityInCurrentSelection";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = findEntityDataInCurrentSelection;
7
- var _findEntityInCurrentSelection = _interopRequireDefault(require("./findEntityInCurrentSelection"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
3
  // get data for the entity
10
- function findEntityDataInCurrentSelection(editorState, entityType) {
11
- var _findEntityInCurrentS = (0, _findEntityInCurrentSelection["default"])(editorState, entityType),
4
+ export default function findEntityDataInCurrentSelection(editorState, entityType) {
5
+ var _findEntityInCurrentS = findEntityInCurrentSelection(editorState, entityType),
12
6
  entity = _findEntityInCurrentS.entity;
13
7
  if (entity) {
14
8
  var data = entity.getData();
@@ -1,20 +1,14 @@
1
- "use strict";
1
+ import { SelectionState } from "draft-js";
2
+ import rangesIntersect from "./rangesIntersect";
3
+ import selectionIsInOneBlock from "./selectionIsInOneBlock";
2
4
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = findEntityInCurrentSelection;
7
- var _draftJs = require("draft-js");
8
- var _rangesIntersect = _interopRequireDefault(require("./rangesIntersect"));
9
- var _selectionIsInOneBlock = _interopRequireDefault(require("./selectionIsInOneBlock"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
5
  //
12
6
  // Searches for entities in the current selection
13
7
  // If entity found, we return the first entity found and a selection of this entity and the text of this entity
14
8
  //
15
- function findEntityInCurrentSelection(editorState, entityType) {
9
+ export default function findEntityInCurrentSelection(editorState, entityType) {
16
10
  // we dont support selections over multiple content blocks
17
- if (!(0, _selectionIsInOneBlock["default"])(editorState)) {
11
+ if (!selectionIsInOneBlock(editorState)) {
18
12
  return {
19
13
  entity: null,
20
14
  entitySelection: null,
@@ -47,7 +41,7 @@ function findEntityInCurrentSelection(editorState, entityType) {
47
41
  }, function (start, end) {
48
42
  if (!firstFoundLinkEntity) {
49
43
  // if we 've found one already we're done
50
- if ((0, _rangesIntersect["default"])([selection.getStartOffset(), selection.getEndOffset()], [start, end])) {
44
+ if (rangesIntersect([selection.getStartOffset(), selection.getEndOffset()], [start, end])) {
51
45
  // we are only interested in entities within the current selection
52
46
  var innerEntityKey = blockAtBeginning.getEntityAt(start);
53
47
  var entity = contentState.getEntity(innerEntityKey);
@@ -58,7 +52,7 @@ function findEntityInCurrentSelection(editorState, entityType) {
58
52
  firstFoundLinkEntity = entity;
59
53
  entityText = blockAtBeginning.getText().slice(start, end);
60
54
  entityKey = innerEntityKey;
61
- entitySelection = new _draftJs.SelectionState({
55
+ entitySelection = new SelectionState({
62
56
  anchorKey: startKey,
63
57
  anchorOffset: start,
64
58
  focusKey: startKey,
@@ -1,14 +1,8 @@
1
- "use strict";
1
+ import selectionIsInOneBlock from "./selectionIsInOneBlock";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = findTextInCurrentSelection;
7
- var _selectionIsInOneBlock = _interopRequireDefault(require("./selectionIsInOneBlock"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
3
  // returns the text of the current selection
10
- function findTextInCurrentSelection(editorState) {
11
- if (!(0, _selectionIsInOneBlock["default"])(editorState)) {
4
+ export default function findTextInCurrentSelection(editorState) {
5
+ if (!selectionIsInOneBlock(editorState)) {
12
6
  return "";
13
7
  }
14
8
  var selectionState = editorState.getSelection();
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = getCurrentBlock;
7
- function getCurrentBlock(editorState) {
1
+ export default function getCurrentBlock(editorState) {
8
2
  var selection = editorState.getSelection();
9
3
  if (!selection) {
10
4
  return null;
@@ -1,24 +1,18 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _admin = require("@comet/admin");
8
- var _colors = require("@mui/material/colors");
9
- var _default = exports["default"] = function _default(themeProps) {
1
+ import { greyPalette, primaryPalette } from "@comet/admin";
2
+ import { grey as muiGreyPalette } from "@mui/material/colors";
3
+ export default (function (themeProps) {
10
4
  var _themeProps$colors, _themeProps$colors2, _themeProps$colors3, _themeProps$colors4, _themeProps$colors5, _themeProps$colors6, _themeProps$colors7, _themeProps$colors8, _themeProps$colors9;
11
5
  return {
12
6
  colors: {
13
- border: themeProps !== null && themeProps !== void 0 && (_themeProps$colors = themeProps.colors) !== null && _themeProps$colors !== void 0 && _themeProps$colors.border ? themeProps.colors.border : _admin.greyPalette[100],
14
- outerBorderOnHover: themeProps !== null && themeProps !== void 0 && (_themeProps$colors2 = themeProps.colors) !== null && _themeProps$colors2 !== void 0 && _themeProps$colors2.outerBorderOnHover ? themeProps.colors.outerBorderOnHover : _admin.greyPalette[200],
15
- outerBorderOnFocus: themeProps !== null && themeProps !== void 0 && (_themeProps$colors3 = themeProps.colors) !== null && _themeProps$colors3 !== void 0 && _themeProps$colors3.outerBorderOnFocus ? themeProps.colors.outerBorderOnFocus : _admin.primaryPalette.main,
16
- toolbarBackground: themeProps !== null && themeProps !== void 0 && (_themeProps$colors4 = themeProps.colors) !== null && _themeProps$colors4 !== void 0 && _themeProps$colors4.toolbarBackground ? themeProps.colors.toolbarBackground : _colors.grey[100],
17
- buttonIcon: themeProps !== null && themeProps !== void 0 && (_themeProps$colors5 = themeProps.colors) !== null && _themeProps$colors5 !== void 0 && _themeProps$colors5.buttonIcon ? themeProps.colors.buttonIcon : _colors.grey[600],
18
- buttonIconDisabled: themeProps !== null && themeProps !== void 0 && (_themeProps$colors6 = themeProps.colors) !== null && _themeProps$colors6 !== void 0 && _themeProps$colors6.buttonIconDisabled ? themeProps.colors.buttonIconDisabled : _colors.grey[300],
19
- buttonBackgroundHover: themeProps !== null && themeProps !== void 0 && (_themeProps$colors7 = themeProps.colors) !== null && _themeProps$colors7 !== void 0 && _themeProps$colors7.buttonBackgroundHover ? themeProps.colors.buttonBackgroundHover : _colors.grey[200],
20
- buttonBorderHover: themeProps !== null && themeProps !== void 0 && (_themeProps$colors8 = themeProps.colors) !== null && _themeProps$colors8 !== void 0 && _themeProps$colors8.buttonBorderHover ? themeProps.colors.buttonBorderHover : _colors.grey[400],
21
- buttonBorderDisabled: themeProps !== null && themeProps !== void 0 && (_themeProps$colors9 = themeProps.colors) !== null && _themeProps$colors9 !== void 0 && _themeProps$colors9.buttonBorderDisabled ? themeProps.colors.buttonBorderDisabled : _colors.grey[100]
7
+ border: themeProps !== null && themeProps !== void 0 && (_themeProps$colors = themeProps.colors) !== null && _themeProps$colors !== void 0 && _themeProps$colors.border ? themeProps.colors.border : greyPalette[100],
8
+ outerBorderOnHover: themeProps !== null && themeProps !== void 0 && (_themeProps$colors2 = themeProps.colors) !== null && _themeProps$colors2 !== void 0 && _themeProps$colors2.outerBorderOnHover ? themeProps.colors.outerBorderOnHover : greyPalette[200],
9
+ outerBorderOnFocus: themeProps !== null && themeProps !== void 0 && (_themeProps$colors3 = themeProps.colors) !== null && _themeProps$colors3 !== void 0 && _themeProps$colors3.outerBorderOnFocus ? themeProps.colors.outerBorderOnFocus : primaryPalette.main,
10
+ toolbarBackground: themeProps !== null && themeProps !== void 0 && (_themeProps$colors4 = themeProps.colors) !== null && _themeProps$colors4 !== void 0 && _themeProps$colors4.toolbarBackground ? themeProps.colors.toolbarBackground : muiGreyPalette[100],
11
+ buttonIcon: themeProps !== null && themeProps !== void 0 && (_themeProps$colors5 = themeProps.colors) !== null && _themeProps$colors5 !== void 0 && _themeProps$colors5.buttonIcon ? themeProps.colors.buttonIcon : muiGreyPalette[600],
12
+ buttonIconDisabled: themeProps !== null && themeProps !== void 0 && (_themeProps$colors6 = themeProps.colors) !== null && _themeProps$colors6 !== void 0 && _themeProps$colors6.buttonIconDisabled ? themeProps.colors.buttonIconDisabled : muiGreyPalette[300],
13
+ buttonBackgroundHover: themeProps !== null && themeProps !== void 0 && (_themeProps$colors7 = themeProps.colors) !== null && _themeProps$colors7 !== void 0 && _themeProps$colors7.buttonBackgroundHover ? themeProps.colors.buttonBackgroundHover : muiGreyPalette[200],
14
+ buttonBorderHover: themeProps !== null && themeProps !== void 0 && (_themeProps$colors8 = themeProps.colors) !== null && _themeProps$colors8 !== void 0 && _themeProps$colors8.buttonBorderHover ? themeProps.colors.buttonBorderHover : muiGreyPalette[400],
15
+ buttonBorderDisabled: themeProps !== null && themeProps !== void 0 && (_themeProps$colors9 = themeProps.colors) !== null && _themeProps$colors9 !== void 0 && _themeProps$colors9.buttonBorderDisabled ? themeProps.colors.buttonBorderDisabled : muiGreyPalette[100]
22
16
  }
23
17
  };
24
- };
18
+ });
@@ -1,23 +1,17 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.pasteAndFilterText = pasteAndFilterText;
7
- var _draftjsConductor = require("draftjs-conductor");
8
- var _default = _interopRequireDefault(require("../filterEditor/default"));
9
- var _Rte = require("../Rte");
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
12
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
4
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
15
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
16
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { handleDraftEditorPastedText } from "draftjs-conductor";
8
+ import defaultFilterEditorStateBeforeUpdate from "../filterEditor/default";
9
+ import { defaultOptions } from "../Rte";
17
10
  function pasteAndFilterText(html, editorState, options) {
18
- var nextEditorState = (0, _draftjsConductor.handleDraftEditorPastedText)(html, editorState);
11
+ var nextEditorState = handleDraftEditorPastedText(html, editorState);
19
12
  if (nextEditorState) {
20
- return (0, _default["default"])(nextEditorState, _objectSpread(_objectSpread({}, _Rte.defaultOptions), options));
13
+ return defaultFilterEditorStateBeforeUpdate(nextEditorState, _objectSpread(_objectSpread({}, defaultOptions), options));
21
14
  }
22
15
  return false;
23
- }
16
+ }
17
+ export { pasteAndFilterText };
@@ -1,16 +1,10 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = rangesIntersect;
7
1
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
8
2
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
3
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
10
4
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
6
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
13
- function rangesIntersect(a, b) {
7
+ export default function rangesIntersect(a, b) {
14
8
  var positiveWhenRangesTouch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
15
9
  var _a = _slicedToArray(a, 2),
16
10
  aStart = _a[0],
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = selectionIsInOneBlock;
7
- function selectionIsInOneBlock(editorState) {
1
+ export default function selectionIsInOneBlock(editorState) {
8
2
  var selection = editorState.getSelection();
9
3
  var startKey = selection.getStartKey();
10
4
  var endKey = selection.getEndKey();
@@ -1,18 +1,6 @@
1
- "use strict";
2
-
3
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports["default"] = void 0;
8
- var _react = require("react");
9
- var _makeRteApi3 = _interopRequireDefault(require("../core/makeRteApi"));
10
- var _Rte = require("../core/Rte");
11
- var _RteReadOnly = _interopRequireDefault(require("../core/RteReadOnly"));
12
- var _jsxRuntime = require("react/jsx-runtime");
13
2
  var _excluded = ["value", "onChange"],
14
3
  _excluded2 = ["input", "meta", "value"];
15
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
16
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
6
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -26,6 +14,11 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
26
14
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
27
15
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
28
16
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
17
+ import { useRef } from "react";
18
+ import makeRteApi from "../core/makeRteApi";
19
+ import { Rte } from "../core/Rte";
20
+ import RteReadOnlyBase from "../core/RteReadOnly";
21
+ import { jsx as _jsx } from "react/jsx-runtime";
29
22
  var defaultConfig = {};
30
23
 
31
24
  /**
@@ -37,7 +30,7 @@ function createFinalFormRte() {
37
30
  var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultConfig;
38
31
  var rteApiOptions = config.rteApiOptions,
39
32
  rteOptions = config.rteOptions;
40
- var _makeRteApi = (0, _makeRteApi3["default"])(rteApiOptions),
33
+ var _makeRteApi = makeRteApi(rteApiOptions),
41
34
  _makeRteApi2 = _slicedToArray(_makeRteApi, 2),
42
35
  useRteApi = _makeRteApi2[0],
43
36
  createStateFromRawContent = _makeRteApi2[1].createStateFromRawContent;
@@ -49,7 +42,7 @@ function createFinalFormRte() {
49
42
  meta = _ref.meta,
50
43
  remove = _ref.value,
51
44
  rest = _objectWithoutProperties(_ref, _excluded2);
52
- var ref = (0, _react.useRef)();
45
+ var ref = useRef(undefined);
53
46
  var onDebouncedContentChange = function onDebouncedContentChange(debouncedEditorState, convertStateToRawContent) {
54
47
  onChange(convertStateToRawContent(debouncedEditorState));
55
48
  };
@@ -59,7 +52,7 @@ function createFinalFormRte() {
59
52
  }),
60
53
  editorState = _useRteApi.editorState,
61
54
  setEditorState = _useRteApi.setEditorState;
62
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Rte.Rte, _objectSpread(_objectSpread({
55
+ return /*#__PURE__*/_jsx(Rte, _objectSpread(_objectSpread({
63
56
  ref: ref,
64
57
  value: editorState,
65
58
  onChange: function onChange(c) {
@@ -74,7 +67,7 @@ function createFinalFormRte() {
74
67
  if (!content) {
75
68
  return null;
76
69
  }
77
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_RteReadOnly["default"], {
70
+ return /*#__PURE__*/_jsx(RteReadOnlyBase, {
78
71
  value: createStateFromRawContent(content),
79
72
  plainTextOnly: plainTextOnly,
80
73
  options: {
@@ -88,4 +81,4 @@ function createFinalFormRte() {
88
81
  RteReadOnly: RteReadOnly
89
82
  };
90
83
  }
91
- var _default = exports["default"] = createFinalFormRte;
84
+ export default createFinalFormRte;
@@ -1,16 +1,5 @@
1
- "use strict";
2
-
3
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createRteField = void 0;
8
- var _admin = require("@comet/admin");
9
- var _requiredValidator = require("../utils/requiredValidator");
10
- var _createFinalFormRte2 = _interopRequireDefault(require("./createFinalFormRte"));
11
- var _jsxRuntime = require("react/jsx-runtime");
12
2
  var _excluded = ["required", "validate"];
13
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
14
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
5
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -18,6 +7,10 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
18
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19
8
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
20
9
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
10
+ import { Field } from "@comet/admin";
11
+ import { requiredValidator } from "../utils/requiredValidator";
12
+ import createFinalFormRte from "./createFinalFormRte";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
21
14
  // Same as in `Field` from `@comet/admin`
22
15
  var composeValidators = function composeValidators() {
23
16
  for (var _len = arguments.length, validators = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -29,16 +22,16 @@ var composeValidators = function composeValidators() {
29
22
  }, undefined);
30
23
  };
31
24
  };
32
- var createRteField = exports.createRteField = function createRteField(config) {
33
- var _createFinalFormRte = (0, _createFinalFormRte2["default"])(config),
25
+ export var createRteField = function createRteField(config) {
26
+ var _createFinalFormRte = createFinalFormRte(config),
34
27
  RteFieldComponent = _createFinalFormRte.RteField,
35
28
  RteReadOnly = _createFinalFormRte.RteReadOnly;
36
29
  var RteField = function RteField(_ref) {
37
30
  var required = _ref.required,
38
31
  validate = _ref.validate,
39
32
  restProps = _objectWithoutProperties(_ref, _excluded);
40
- var validateError = required ? validate ? composeValidators(_requiredValidator.requiredValidator, validate) : _requiredValidator.requiredValidator : validate;
41
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_admin.Field, _objectSpread({
33
+ var validateError = required ? validate ? composeValidators(requiredValidator, validate) : requiredValidator : validate;
34
+ return /*#__PURE__*/_jsx(Field, _objectSpread({
42
35
  component: RteFieldComponent,
43
36
  required: required,
44
37
  validate: validateError