@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.
- package/lib/core/BlockElement.js +11 -15
- package/lib/core/Controls/BlockTypesControls.js +17 -24
- package/lib/core/Controls/ControlButton.js +11 -18
- package/lib/core/Controls/Controls.js +14 -21
- package/lib/core/Controls/CustomControls.js +5 -12
- package/lib/core/Controls/FeaturesButtonGroup.d.ts +1 -1
- package/lib/core/Controls/FeaturesButtonGroup.d.ts.map +1 -1
- package/lib/core/Controls/FeaturesButtonGroup.js +35 -41
- package/lib/core/Controls/HistoryContols.js +6 -13
- package/lib/core/Controls/InlineStyleTypeControls.js +6 -13
- package/lib/core/Controls/LinkControls.js +19 -26
- package/lib/core/Controls/ListsControls.js +6 -13
- package/lib/core/Controls/ListsIndentControls.js +6 -13
- package/lib/core/Controls/SpecialCharactersControls.js +7 -14
- package/lib/core/Controls/Toolbar/Toolbar.d.ts +1 -0
- package/lib/core/Controls/Toolbar/Toolbar.d.ts.map +1 -1
- package/lib/core/Controls/Toolbar/Toolbar.js +9 -15
- package/lib/core/Controls/Toolbar/Toolbar.styles.d.ts +2 -2
- package/lib/core/Controls/Toolbar/Toolbar.styles.js +7 -14
- package/lib/core/Controls/TranslationControls.js +8 -15
- package/lib/core/Controls/useBlockTypes.d.ts +1 -1
- package/lib/core/Controls/useBlockTypes.d.ts.map +1 -1
- package/lib/core/Controls/useBlockTypes.js +16 -23
- package/lib/core/Controls/useHistory.js +16 -22
- package/lib/core/Controls/useInlineStyleType.d.ts +1 -1
- package/lib/core/Controls/useInlineStyleType.d.ts.map +1 -1
- package/lib/core/Controls/useInlineStyleType.js +30 -37
- package/lib/core/Controls/useListIndent.js +23 -29
- package/lib/core/Rte.js +47 -54
- package/lib/core/RteReadOnly.js +18 -25
- package/lib/core/defaultBlocktypeMap.js +30 -38
- package/lib/core/extension/Link/Decorator.js +4 -11
- package/lib/core/extension/Link/EditorComponent.js +3 -9
- package/lib/core/extension/Link/ToolbarButton.js +50 -55
- package/lib/core/extension/LinksRemove/ToolbarButton.js +8 -14
- package/lib/core/extension/NonBreakingSpace/Decorator.js +3 -10
- package/lib/core/extension/NonBreakingSpace/EditorComponent.js +8 -14
- package/lib/core/extension/NonBreakingSpace/ToolbarButton.js +15 -23
- package/lib/core/extension/SoftHyphen/Decorator.js +3 -9
- package/lib/core/extension/SoftHyphen/EditorComponent.js +7 -13
- package/lib/core/extension/SoftHyphen/ToolbarButton.js +14 -22
- package/lib/core/filterEditor/composeFilterEditorFns.js +1 -7
- package/lib/core/filterEditor/default.js +9 -16
- package/lib/core/filterEditor/manageStandardBlockType.js +3 -9
- package/lib/core/filterEditor/removeBlocksExceedingBlockLimit.js +4 -10
- package/lib/core/filterEditor/removeUnsupportedBlockTypes.js +3 -10
- package/lib/core/filterEditor/removeUnsupportedEntities.js +3 -10
- package/lib/core/filterEditor/removeUnsupportedInlineStyles.js +3 -10
- package/lib/core/filterEditor/removeUnsupportedListLevels.js +3 -9
- package/lib/core/filterEditor/utils/changeBlockType.js +3 -9
- package/lib/core/filterEditor/utils/manipulateEntityData.js +3 -9
- package/lib/core/filterEditor/utils/removeEntities.js +4 -10
- package/lib/core/filterEditor/utils/removeInlineStyles.js +4 -10
- package/lib/core/makeRteApi.js +19 -26
- package/lib/core/translation/EditorStateTranslationDialog.js +8 -15
- package/lib/core/translation/ToolbarButton.js +22 -28
- package/lib/core/translation/htmlToState.js +7 -13
- package/lib/core/translation/stateToHtml.js +5 -12
- package/lib/core/types.d.ts +2 -2
- package/lib/core/types.d.ts.map +1 -1
- package/lib/core/types.js +1 -5
- package/lib/core/utils/createBlockRenderMap.js +4 -12
- package/lib/core/utils/findEntityDataInCurrentSelection.js +3 -9
- package/lib/core/utils/findEntityInCurrentSelection.js +7 -13
- package/lib/core/utils/findTextInCurrentSelection.js +3 -9
- package/lib/core/utils/getCurrentBlock.js +1 -7
- package/lib/core/utils/getRteTheme.js +13 -19
- package/lib/core/utils/pasteAndFilterText.js +7 -13
- package/lib/core/utils/rangesIntersect.js +1 -7
- package/lib/core/utils/selectionIsInOneBlock.js +1 -7
- package/lib/field/createFinalFormRte.js +10 -17
- package/lib/field/createRteField.js +8 -15
- package/lib/index.js +28 -202
- package/lib/useDebounce.js +5 -10
- package/lib/usePrevious.js +4 -9
- package/lib/utils/requiredValidator.js +6 -12
- package/package.json +18 -14
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.cleanBlockTypeMap = cleanBlockTypeMap;
|
|
7
|
-
exports["default"] = void 0;
|
|
8
|
-
exports.mergeBlocktypeMaps = mergeBlocktypeMaps;
|
|
9
|
-
var _adminIcons = require("@comet/admin-icons");
|
|
10
|
-
var _reactIntl = require("react-intl");
|
|
11
|
-
var _BlockElement = require("./BlockElement");
|
|
12
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
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); }
|
|
14
2
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
15
3
|
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."); }
|
|
@@ -22,7 +10,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
22
10
|
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; }
|
|
23
11
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
24
12
|
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); }
|
|
25
|
-
|
|
13
|
+
import { RteOl, RteUl } from "@comet/admin-icons";
|
|
14
|
+
import { defineMessage, FormattedMessage } from "react-intl";
|
|
15
|
+
import { BlockElement } from "./BlockElement";
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
var headerMessage = defineMessage({
|
|
26
18
|
id: "comet.rte.controls.blockType.heading",
|
|
27
19
|
defaultMessage: "Heading {level}"
|
|
28
20
|
});
|
|
@@ -31,18 +23,18 @@ var defaultBlocktypeMap = {
|
|
|
31
23
|
// other values are ignored
|
|
32
24
|
unstyled: {
|
|
33
25
|
//info: https://draftjs.org/docs/advanced-topics-custom-block-render-map/#configuring-block-render-map
|
|
34
|
-
label: /*#__PURE__*/(
|
|
26
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
35
27
|
id: "comet.rte.controls.blockType.default",
|
|
36
28
|
defaultMessage: "Default"
|
|
37
29
|
}),
|
|
38
30
|
renderConfig: {
|
|
39
|
-
element:
|
|
31
|
+
element: BlockElement,
|
|
40
32
|
aliasedElements: ["p"]
|
|
41
33
|
}
|
|
42
34
|
},
|
|
43
35
|
"header-one": {
|
|
44
36
|
supportedBy: "header-one",
|
|
45
|
-
label: /*#__PURE__*/(
|
|
37
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, _objectSpread(_objectSpread({}, headerMessage), {}, {
|
|
46
38
|
values: {
|
|
47
39
|
level: 1
|
|
48
40
|
}
|
|
@@ -50,7 +42,7 @@ var defaultBlocktypeMap = {
|
|
|
50
42
|
group: "dropdown",
|
|
51
43
|
renderConfig: {
|
|
52
44
|
element: function element(p) {
|
|
53
|
-
return /*#__PURE__*/(
|
|
45
|
+
return /*#__PURE__*/_jsx(BlockElement, _objectSpread({
|
|
54
46
|
type: "header-one",
|
|
55
47
|
variant: "h1"
|
|
56
48
|
}, p));
|
|
@@ -60,7 +52,7 @@ var defaultBlocktypeMap = {
|
|
|
60
52
|
},
|
|
61
53
|
"header-two": {
|
|
62
54
|
supportedBy: "header-two",
|
|
63
|
-
label: /*#__PURE__*/(
|
|
55
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, _objectSpread(_objectSpread({}, headerMessage), {}, {
|
|
64
56
|
values: {
|
|
65
57
|
level: 2
|
|
66
58
|
}
|
|
@@ -68,7 +60,7 @@ var defaultBlocktypeMap = {
|
|
|
68
60
|
group: "dropdown",
|
|
69
61
|
renderConfig: {
|
|
70
62
|
element: function element(p) {
|
|
71
|
-
return /*#__PURE__*/(
|
|
63
|
+
return /*#__PURE__*/_jsx(BlockElement, _objectSpread({
|
|
72
64
|
type: "header-two",
|
|
73
65
|
variant: "h2"
|
|
74
66
|
}, p));
|
|
@@ -78,7 +70,7 @@ var defaultBlocktypeMap = {
|
|
|
78
70
|
},
|
|
79
71
|
"header-three": {
|
|
80
72
|
supportedBy: "header-three",
|
|
81
|
-
label: /*#__PURE__*/(
|
|
73
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, _objectSpread(_objectSpread({}, headerMessage), {}, {
|
|
82
74
|
values: {
|
|
83
75
|
level: 3
|
|
84
76
|
}
|
|
@@ -86,7 +78,7 @@ var defaultBlocktypeMap = {
|
|
|
86
78
|
group: "dropdown",
|
|
87
79
|
renderConfig: {
|
|
88
80
|
element: function element(p) {
|
|
89
|
-
return /*#__PURE__*/(
|
|
81
|
+
return /*#__PURE__*/_jsx(BlockElement, _objectSpread({
|
|
90
82
|
type: "header-three",
|
|
91
83
|
variant: "h3"
|
|
92
84
|
}, p));
|
|
@@ -96,7 +88,7 @@ var defaultBlocktypeMap = {
|
|
|
96
88
|
},
|
|
97
89
|
"header-four": {
|
|
98
90
|
supportedBy: "header-four",
|
|
99
|
-
label: /*#__PURE__*/(
|
|
91
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, _objectSpread(_objectSpread({}, headerMessage), {}, {
|
|
100
92
|
values: {
|
|
101
93
|
level: 4
|
|
102
94
|
}
|
|
@@ -104,7 +96,7 @@ var defaultBlocktypeMap = {
|
|
|
104
96
|
group: "dropdown",
|
|
105
97
|
renderConfig: {
|
|
106
98
|
element: function element(p) {
|
|
107
|
-
return /*#__PURE__*/(
|
|
99
|
+
return /*#__PURE__*/_jsx(BlockElement, _objectSpread({
|
|
108
100
|
type: "header-four",
|
|
109
101
|
variant: "h4"
|
|
110
102
|
}, p));
|
|
@@ -114,7 +106,7 @@ var defaultBlocktypeMap = {
|
|
|
114
106
|
},
|
|
115
107
|
"header-five": {
|
|
116
108
|
supportedBy: "header-five",
|
|
117
|
-
label: /*#__PURE__*/(
|
|
109
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, _objectSpread(_objectSpread({}, headerMessage), {}, {
|
|
118
110
|
values: {
|
|
119
111
|
level: 5
|
|
120
112
|
}
|
|
@@ -122,7 +114,7 @@ var defaultBlocktypeMap = {
|
|
|
122
114
|
group: "dropdown",
|
|
123
115
|
renderConfig: {
|
|
124
116
|
element: function element(p) {
|
|
125
|
-
return /*#__PURE__*/(
|
|
117
|
+
return /*#__PURE__*/_jsx(BlockElement, _objectSpread({
|
|
126
118
|
type: "header-five",
|
|
127
119
|
variant: "h5"
|
|
128
120
|
}, p));
|
|
@@ -132,7 +124,7 @@ var defaultBlocktypeMap = {
|
|
|
132
124
|
},
|
|
133
125
|
"header-six": {
|
|
134
126
|
supportedBy: "header-six",
|
|
135
|
-
label: /*#__PURE__*/(
|
|
127
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, _objectSpread(_objectSpread({}, headerMessage), {}, {
|
|
136
128
|
values: {
|
|
137
129
|
level: 6
|
|
138
130
|
}
|
|
@@ -140,7 +132,7 @@ var defaultBlocktypeMap = {
|
|
|
140
132
|
group: "dropdown",
|
|
141
133
|
renderConfig: {
|
|
142
134
|
element: function element(p) {
|
|
143
|
-
return /*#__PURE__*/(
|
|
135
|
+
return /*#__PURE__*/_jsx(BlockElement, _objectSpread({
|
|
144
136
|
type: "header-six",
|
|
145
137
|
variant: "h6"
|
|
146
138
|
}, p));
|
|
@@ -150,13 +142,13 @@ var defaultBlocktypeMap = {
|
|
|
150
142
|
},
|
|
151
143
|
blockquote: {
|
|
152
144
|
supportedBy: "blockquote",
|
|
153
|
-
label: /*#__PURE__*/(
|
|
145
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
154
146
|
id: "comet.rte.controls.blockType.blockquote",
|
|
155
147
|
defaultMessage: "Blockquote"
|
|
156
148
|
}),
|
|
157
149
|
renderConfig: {
|
|
158
150
|
element: function element(p) {
|
|
159
|
-
return /*#__PURE__*/(
|
|
151
|
+
return /*#__PURE__*/_jsx(BlockElement, _objectSpread({
|
|
160
152
|
type: "blockquote"
|
|
161
153
|
}, p));
|
|
162
154
|
},
|
|
@@ -166,13 +158,13 @@ var defaultBlocktypeMap = {
|
|
|
166
158
|
"unordered-list-item": {
|
|
167
159
|
supportedBy: "unordered-list",
|
|
168
160
|
group: "button",
|
|
169
|
-
label: /*#__PURE__*/(
|
|
161
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
170
162
|
id: "comet.rte.controls.blockType.unorderedList",
|
|
171
163
|
defaultMessage: "Bulletpoints"
|
|
172
164
|
}),
|
|
173
|
-
icon:
|
|
165
|
+
icon: RteUl,
|
|
174
166
|
renderConfig: {
|
|
175
|
-
wrapper: /*#__PURE__*/(
|
|
167
|
+
wrapper: /*#__PURE__*/_jsx(BlockElement, {
|
|
176
168
|
type: "unordered-list",
|
|
177
169
|
component: "ul"
|
|
178
170
|
}),
|
|
@@ -184,13 +176,13 @@ var defaultBlocktypeMap = {
|
|
|
184
176
|
"ordered-list-item": {
|
|
185
177
|
supportedBy: "ordered-list",
|
|
186
178
|
group: "button",
|
|
187
|
-
label: /*#__PURE__*/(
|
|
179
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
188
180
|
id: "comet.rte.controls.blockType.orderedList",
|
|
189
181
|
defaultMessage: "Numbering"
|
|
190
182
|
}),
|
|
191
|
-
icon:
|
|
183
|
+
icon: RteOl,
|
|
192
184
|
renderConfig: {
|
|
193
|
-
wrapper: /*#__PURE__*/(
|
|
185
|
+
wrapper: /*#__PURE__*/_jsx(BlockElement, {
|
|
194
186
|
type: "ordered-list",
|
|
195
187
|
component: "ol"
|
|
196
188
|
}),
|
|
@@ -198,7 +190,7 @@ var defaultBlocktypeMap = {
|
|
|
198
190
|
}
|
|
199
191
|
}
|
|
200
192
|
};
|
|
201
|
-
function mergeBlocktypeMaps() {
|
|
193
|
+
export function mergeBlocktypeMaps() {
|
|
202
194
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
203
195
|
args[_key] = arguments[_key];
|
|
204
196
|
}
|
|
@@ -227,7 +219,7 @@ function mergeBlocktypeMaps() {
|
|
|
227
219
|
return newEl;
|
|
228
220
|
}); // merge 2 levels nested
|
|
229
221
|
}
|
|
230
|
-
function cleanBlockTypeMap(map) {
|
|
222
|
+
export function cleanBlockTypeMap(map) {
|
|
231
223
|
// these unsupportedKeysForUnstyled canot be changed
|
|
232
224
|
var unsupportedKeysForUnstyled = ["group", "icon", "supportedBy"];
|
|
233
225
|
if (map !== null && map !== void 0 && map.unstyled) {
|
|
@@ -240,4 +232,4 @@ function cleanBlockTypeMap(map) {
|
|
|
240
232
|
}
|
|
241
233
|
return map;
|
|
242
234
|
}
|
|
243
|
-
|
|
235
|
+
export default defaultBlocktypeMap;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = exports.ENTITY_TYPE = void 0;
|
|
7
|
-
var _EditorComponent = _interopRequireDefault(require("./EditorComponent"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
-
var ENTITY_TYPE = exports.ENTITY_TYPE = "LINK";
|
|
1
|
+
import EditorComponent from "./EditorComponent";
|
|
2
|
+
export var ENTITY_TYPE = "LINK";
|
|
10
3
|
var Decorator = {
|
|
11
4
|
strategy: function strategy(contentBlock, callback, contentState) {
|
|
12
5
|
// findEntities
|
|
@@ -15,6 +8,6 @@ var Decorator = {
|
|
|
15
8
|
return entityKey !== null && contentState.getEntity(entityKey).getType() === ENTITY_TYPE;
|
|
16
9
|
}, callback);
|
|
17
10
|
},
|
|
18
|
-
component:
|
|
11
|
+
component: EditorComponent
|
|
19
12
|
};
|
|
20
|
-
|
|
13
|
+
export default Decorator;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
2
|
var EditorComponent = function EditorComponent(props) {
|
|
9
3
|
var _ref = props.contentState.getEntity(props.entityKey).getData(),
|
|
10
4
|
url = _ref.url; // not typed
|
|
11
|
-
return /*#__PURE__*/(
|
|
5
|
+
return /*#__PURE__*/_jsx("a", {
|
|
12
6
|
href: url,
|
|
13
7
|
style: {
|
|
14
8
|
color: "#3b5998",
|
|
@@ -17,4 +11,4 @@ var EditorComponent = function EditorComponent(props) {
|
|
|
17
11
|
children: props.children
|
|
18
12
|
});
|
|
19
13
|
};
|
|
20
|
-
|
|
14
|
+
export default EditorComponent;
|
|
@@ -1,39 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = ToolbarButton;
|
|
7
|
-
var _admin = require("@comet/admin");
|
|
8
|
-
var _adminIcons = require("@comet/admin-icons");
|
|
9
|
-
var _material = require("@mui/material");
|
|
10
|
-
var _draftJs = require("draft-js");
|
|
11
|
-
var _react = require("react");
|
|
12
|
-
var _reactIntl = require("react-intl");
|
|
13
|
-
var _ControlButton = require("../../Controls/ControlButton");
|
|
14
|
-
var _findEntityDataInCurrentSelection = _interopRequireDefault(require("../../utils/findEntityDataInCurrentSelection"));
|
|
15
|
-
var _findEntityInCurrentSelection = _interopRequireDefault(require("../../utils/findEntityInCurrentSelection"));
|
|
16
|
-
var _selectionIsInOneBlock = _interopRequireDefault(require("../../utils/selectionIsInOneBlock"));
|
|
17
|
-
var _Decorator = require("./Decorator");
|
|
18
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
20
1
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
21
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."); }
|
|
22
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; } }
|
|
23
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; }
|
|
24
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; } }
|
|
25
6
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
26
|
-
|
|
27
|
-
|
|
7
|
+
import { Button } from "@comet/admin";
|
|
8
|
+
import { Check, Close, Delete, RteLink } from "@comet/admin-icons";
|
|
9
|
+
import {
|
|
10
|
+
// eslint-disable-next-line no-restricted-imports
|
|
11
|
+
Dialog, DialogActions, DialogContent, DialogTitle, FormControl, FormLabel, Grid, InputBase } from "@mui/material";
|
|
12
|
+
import { EditorState, RichUtils } from "draft-js";
|
|
13
|
+
import { useEffect, useState } from "react";
|
|
14
|
+
import { FormattedMessage } from "react-intl";
|
|
15
|
+
import { ControlButton } from "../../Controls/ControlButton";
|
|
16
|
+
import findEntityDataInCurrentSelection from "../../utils/findEntityDataInCurrentSelection";
|
|
17
|
+
import findEntityInCurrentSelection from "../../utils/findEntityInCurrentSelection";
|
|
18
|
+
import selectionIsInOneBlock from "../../utils/selectionIsInOneBlock";
|
|
19
|
+
import { ENTITY_TYPE } from "./Decorator";
|
|
20
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
export default function ToolbarButton(props) {
|
|
22
|
+
var _useState = useState(false),
|
|
28
23
|
_useState2 = _slicedToArray(_useState, 2),
|
|
29
24
|
open = _useState2[0],
|
|
30
25
|
setOpen = _useState2[1];
|
|
31
|
-
var linkData = (
|
|
32
|
-
var _findEntityInCurrentS = (
|
|
26
|
+
var linkData = findEntityDataInCurrentSelection(props.editorState, ENTITY_TYPE);
|
|
27
|
+
var _findEntityInCurrentS = findEntityInCurrentSelection(props.editorState, ENTITY_TYPE),
|
|
33
28
|
previousLinkEntity = _findEntityInCurrentS.entity,
|
|
34
29
|
linkEntitySelection = _findEntityInCurrentS.entitySelection;
|
|
35
30
|
var selection = props.editorState.getSelection();
|
|
36
|
-
var linkEditCreateDisabled = selection.isCollapsed() && !linkData || !(
|
|
31
|
+
var linkEditCreateDisabled = selection.isCollapsed() && !linkData || !selectionIsInOneBlock(props.editorState);
|
|
37
32
|
var globallyDisabled = !!props.disabled;
|
|
38
33
|
function handleClick(e) {
|
|
39
34
|
if (linkEditCreateDisabled) {
|
|
@@ -42,16 +37,16 @@ function ToolbarButton(props) {
|
|
|
42
37
|
if (previousLinkEntity && linkEntitySelection) {
|
|
43
38
|
// when there is a previous LINK entity found in the selection, force-shrink the selection to the text of this link entity
|
|
44
39
|
// like this we avoid nested links
|
|
45
|
-
props.setEditorState(
|
|
40
|
+
props.setEditorState(EditorState.forceSelection(props.editorState, linkEntitySelection));
|
|
46
41
|
}
|
|
47
42
|
setOpen(true);
|
|
48
43
|
}
|
|
49
|
-
return /*#__PURE__*/(
|
|
44
|
+
return /*#__PURE__*/_jsx(ControlButton, {
|
|
50
45
|
selected: !!linkData,
|
|
51
46
|
disabled: linkEditCreateDisabled || globallyDisabled,
|
|
52
|
-
icon:
|
|
47
|
+
icon: RteLink,
|
|
53
48
|
onButtonClick: handleClick,
|
|
54
|
-
children: /*#__PURE__*/(
|
|
49
|
+
children: /*#__PURE__*/_jsx(LinkDialog, {
|
|
55
50
|
editorState: props.editorState,
|
|
56
51
|
onChange: props.setEditorState,
|
|
57
52
|
linkData: linkData,
|
|
@@ -69,11 +64,11 @@ function LinkDialog(props) {
|
|
|
69
64
|
editorState = props.editorState,
|
|
70
65
|
onChange = props.onChange;
|
|
71
66
|
var linkDataUrl = linkData ? linkData.url : "";
|
|
72
|
-
var _useState3 =
|
|
67
|
+
var _useState3 = useState(linkDataUrl),
|
|
73
68
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
74
69
|
newUrl = _useState4[0],
|
|
75
70
|
setNewUrl = _useState4[1];
|
|
76
|
-
|
|
71
|
+
useEffect(function () {
|
|
77
72
|
setNewUrl(linkDataUrl);
|
|
78
73
|
}, [linkDataUrl, setNewUrl]);
|
|
79
74
|
var handleClose = function handleClose() {
|
|
@@ -84,7 +79,7 @@ function LinkDialog(props) {
|
|
|
84
79
|
setNewUrl("");
|
|
85
80
|
var selection = editorState.getSelection();
|
|
86
81
|
if (!selection.isCollapsed()) {
|
|
87
|
-
onChange(
|
|
82
|
+
onChange(RichUtils.toggleLink(editorState, selection, null));
|
|
88
83
|
}
|
|
89
84
|
onClose();
|
|
90
85
|
};
|
|
@@ -95,30 +90,30 @@ function LinkDialog(props) {
|
|
|
95
90
|
url: newUrl
|
|
96
91
|
});
|
|
97
92
|
var entityKey = contentStateWithEntity.getLastCreatedEntityKey();
|
|
98
|
-
var newEditorState =
|
|
93
|
+
var newEditorState = EditorState.set(editorState, {
|
|
99
94
|
currentContent: contentStateWithEntity
|
|
100
95
|
});
|
|
101
|
-
onChange(
|
|
96
|
+
onChange(RichUtils.toggleLink(newEditorState, newEditorState.getSelection(), entityKey));
|
|
102
97
|
onClose();
|
|
103
98
|
};
|
|
104
|
-
return /*#__PURE__*/(
|
|
99
|
+
return /*#__PURE__*/_jsxs(Dialog, {
|
|
105
100
|
onClose: handleClose,
|
|
106
101
|
"aria-labelledby": "simple-dialog-title",
|
|
107
102
|
open: open,
|
|
108
|
-
children: [/*#__PURE__*/(
|
|
109
|
-
children: /*#__PURE__*/(
|
|
103
|
+
children: [/*#__PURE__*/_jsx(DialogTitle, {
|
|
104
|
+
children: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
110
105
|
id: "comet.rte.extensions.link.editDialogTitle",
|
|
111
106
|
defaultMessage: "Link"
|
|
112
107
|
})
|
|
113
|
-
}), /*#__PURE__*/(
|
|
114
|
-
children: /*#__PURE__*/(
|
|
108
|
+
}), /*#__PURE__*/_jsx(DialogContent, {
|
|
109
|
+
children: /*#__PURE__*/_jsxs(FormControl, {
|
|
115
110
|
fullWidth: true,
|
|
116
|
-
children: [/*#__PURE__*/(
|
|
117
|
-
children: /*#__PURE__*/(
|
|
111
|
+
children: [/*#__PURE__*/_jsx(FormLabel, {
|
|
112
|
+
children: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
118
113
|
id: "comet.rte.extensions.link.url",
|
|
119
114
|
defaultMessage: "URL"
|
|
120
115
|
})
|
|
121
|
-
}), /*#__PURE__*/(
|
|
116
|
+
}), /*#__PURE__*/_jsx(InputBase
|
|
122
117
|
// autoFocus
|
|
123
118
|
, {
|
|
124
119
|
value: newUrl,
|
|
@@ -127,34 +122,34 @@ function LinkDialog(props) {
|
|
|
127
122
|
}
|
|
128
123
|
})]
|
|
129
124
|
})
|
|
130
|
-
}), /*#__PURE__*/(
|
|
131
|
-
children: [/*#__PURE__*/(
|
|
125
|
+
}), /*#__PURE__*/_jsxs(DialogActions, {
|
|
126
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
132
127
|
onClick: handleClose,
|
|
133
128
|
variant: "outlined",
|
|
134
|
-
startIcon: /*#__PURE__*/(
|
|
135
|
-
children: /*#__PURE__*/(
|
|
129
|
+
startIcon: /*#__PURE__*/_jsx(Close, {}),
|
|
130
|
+
children: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
136
131
|
id: "comet.generic.cancel",
|
|
137
132
|
defaultMessage: "Cancel"
|
|
138
133
|
})
|
|
139
|
-
}), /*#__PURE__*/(
|
|
140
|
-
children: /*#__PURE__*/(
|
|
134
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
135
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
|
141
136
|
container: true,
|
|
142
137
|
spacing: 4,
|
|
143
|
-
children: [linkData && /*#__PURE__*/(
|
|
144
|
-
children: /*#__PURE__*/(
|
|
145
|
-
startIcon: /*#__PURE__*/(
|
|
138
|
+
children: [linkData && /*#__PURE__*/_jsx(Grid, {
|
|
139
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
140
|
+
startIcon: /*#__PURE__*/_jsx(Delete, {}),
|
|
146
141
|
onClick: handleRemove,
|
|
147
|
-
children: /*#__PURE__*/(
|
|
142
|
+
children: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
148
143
|
id: "comet.generic.delete",
|
|
149
144
|
defaultMessage: "Delete"
|
|
150
145
|
})
|
|
151
146
|
})
|
|
152
|
-
}), /*#__PURE__*/(
|
|
153
|
-
children: /*#__PURE__*/(
|
|
154
|
-
startIcon: /*#__PURE__*/(
|
|
147
|
+
}), /*#__PURE__*/_jsx(Grid, {
|
|
148
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
149
|
+
startIcon: /*#__PURE__*/_jsx(Check, {}),
|
|
155
150
|
onClick: handleUpdate,
|
|
156
151
|
disabled: !newUrl,
|
|
157
|
-
children: /*#__PURE__*/(
|
|
152
|
+
children: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
158
153
|
id: "comet.generic.save",
|
|
159
154
|
defaultMessage: "Save"
|
|
160
155
|
})
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports["default"] = ToolbarButton;
|
|
7
|
-
var _adminIcons = require("@comet/admin-icons");
|
|
8
|
-
var _draftJs = require("draft-js");
|
|
9
|
-
var _ControlButton = require("../../Controls/ControlButton");
|
|
10
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
-
function ToolbarButton(props) {
|
|
1
|
+
import { RteClearLink } from "@comet/admin-icons";
|
|
2
|
+
import { RichUtils } from "draft-js";
|
|
3
|
+
import { ControlButton } from "../../Controls/ControlButton";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
export default function ToolbarButton(props) {
|
|
12
6
|
var selection = props.editorState.getSelection();
|
|
13
7
|
var globallyDisabled = !!props.disabled;
|
|
14
8
|
var buttonEnabled = !selection.isCollapsed(); // @TODO: better to scan the selection if any link-entities are in the selection
|
|
15
9
|
function handleClick(e) {
|
|
16
10
|
e.preventDefault();
|
|
17
11
|
if (buttonEnabled) {
|
|
18
|
-
props.setEditorState(
|
|
12
|
+
props.setEditorState(RichUtils.toggleLink(props.editorState, selection, null)); // @TODO, this removes all entities not only LINK entity, should be improved, now its ok as there are no other entities than links
|
|
19
13
|
}
|
|
20
14
|
}
|
|
21
|
-
return /*#__PURE__*/(
|
|
22
|
-
icon:
|
|
15
|
+
return /*#__PURE__*/_jsx(ControlButton, {
|
|
16
|
+
icon: RteClearLink,
|
|
23
17
|
disabled: globallyDisabled || !buttonEnabled,
|
|
24
18
|
onButtonClick: handleClick
|
|
25
19
|
});
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _EditorComponent = _interopRequireDefault(require("./EditorComponent"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
1
|
+
import EditorComponent from "./EditorComponent";
|
|
9
2
|
var NO_BREAK_SPACE_UNICODE_CHAR = /\u00a0/g;
|
|
10
3
|
var Decorator = {
|
|
11
4
|
strategy: function strategy(contentBlock, callback) {
|
|
12
5
|
findWithRegex(NO_BREAK_SPACE_UNICODE_CHAR, contentBlock, callback);
|
|
13
6
|
},
|
|
14
|
-
component:
|
|
7
|
+
component: EditorComponent
|
|
15
8
|
};
|
|
16
9
|
function findWithRegex(regex, contentBlock, callback) {
|
|
17
10
|
var text = contentBlock.getText();
|
|
@@ -21,4 +14,4 @@ function findWithRegex(regex, contentBlock, callback) {
|
|
|
21
14
|
callback(start, start + matchArr[0].length);
|
|
22
15
|
}
|
|
23
16
|
}
|
|
24
|
-
|
|
17
|
+
export default Decorator;
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _adminIcons = require("@comet/admin-icons");
|
|
8
|
-
var _styles = require("@mui/material/styles");
|
|
9
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
1
|
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
2
|
+
import { RteNonBreakingSpace } from "@comet/admin-icons";
|
|
3
|
+
import { styled } from "@mui/material/styles";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
5
|
var EditorComponent = function EditorComponent(_ref) {
|
|
12
6
|
var children = _ref.children;
|
|
13
|
-
return /*#__PURE__*/(
|
|
14
|
-
children: [/*#__PURE__*/(
|
|
7
|
+
return /*#__PURE__*/_jsxs(Root, {
|
|
8
|
+
children: [/*#__PURE__*/_jsx(Icon, {}), children]
|
|
15
9
|
});
|
|
16
10
|
};
|
|
17
|
-
var Root = /*#__PURE__*/
|
|
11
|
+
var Root = /*#__PURE__*/styled("span", process.env.NODE_ENV === "production" ? {
|
|
18
12
|
target: "e6jub41"
|
|
19
13
|
} : {
|
|
20
14
|
target: "e6jub41",
|
|
@@ -27,7 +21,7 @@ var Root = /*#__PURE__*/(0, _styles.styled)("span", process.env.NODE_ENV === "pr
|
|
|
27
21
|
styles: "position:relative;letter-spacing:0.9em/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb3JlL2V4dGVuc2lvbi9Ob25CcmVha2luZ1NwYWNlL0VkaXRvckNvbXBvbmVudC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBbUIyQiIsImZpbGUiOiIuLi8uLi8uLi8uLi9zcmMvY29yZS9leHRlbnNpb24vTm9uQnJlYWtpbmdTcGFjZS9FZGl0b3JDb21wb25lbnQudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgUnRlTm9uQnJlYWtpbmdTcGFjZSB9IGZyb20gXCJAY29tZXQvYWRtaW4taWNvbnNcIjtcbmltcG9ydCB7IHN0eWxlZCB9IGZyb20gXCJAbXVpL21hdGVyaWFsL3N0eWxlc1wiO1xuaW1wb3J0IHsgdHlwZSBDb250ZW50U3RhdGUgfSBmcm9tIFwiZHJhZnQtanNcIjtcbmltcG9ydCB7IHR5cGUgUHJvcHNXaXRoQ2hpbGRyZW4gfSBmcm9tIFwicmVhY3RcIjtcblxuaW50ZXJmYWNlIFByb3BzIHtcbiAgICBjb250ZW50U3RhdGU6IENvbnRlbnRTdGF0ZTtcbiAgICBlbnRpdHlLZXk6IHN0cmluZztcbn1cblxuY29uc3QgRWRpdG9yQ29tcG9uZW50ID0gKHsgY2hpbGRyZW4gfTogUHJvcHNXaXRoQ2hpbGRyZW48UHJvcHM+KSA9PiB7XG4gICAgcmV0dXJuIChcbiAgICAgICAgPFJvb3Q+XG4gICAgICAgICAgICA8SWNvbiAvPlxuICAgICAgICAgICAge2NoaWxkcmVufVxuICAgICAgICA8L1Jvb3Q+XG4gICAgKTtcbn07XG5cbmNvbnN0IFJvb3QgPSBzdHlsZWQoXCJzcGFuXCIpYFxuICAgIHBvc2l0aW9uOiByZWxhdGl2ZTtcbiAgICAvLyBBcmJpdHJhcnkgdmFsdWUgdG8gbWFrZSB0aGUgbm9uLWJyZWFraW5nIHNwYWNlIHRoZSBzYW1lIHdpZHRoIGFzIHRoZSBpY29uXG4gICAgbGV0dGVyLXNwYWNpbmc6IDAuOWVtO1xuYDtcblxuY29uc3QgSWNvbiA9IHN0eWxlZChSdGVOb25CcmVha2luZ1NwYWNlKWBcbiAgICBwb3NpdGlvbjogYWJzb2x1dGU7XG4gICAgLy8gQXJiaXRyYXJ5IHZhbHVlcyB0byBtYWtlIHRoZSBpY29uIGxvb2sgY2VudGVyZWRcbiAgICB0b3A6IDAuMTJlbTtcbiAgICBsZWZ0OiAwLjA4ZW07XG4gICAgZm9udC1zaXplOiBpbmhlcml0O1xuICAgIGNvbG9yOiBjdXJyZW50Y29sb3I7XG4gICAgb3BhY2l0eTogMC41O1xuYDtcblxuZXhwb3J0IGRlZmF1bHQgRWRpdG9yQ29tcG9uZW50O1xuIl19 */",
|
|
28
22
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
29
23
|
});
|
|
30
|
-
var Icon = /*#__PURE__*/
|
|
24
|
+
var Icon = /*#__PURE__*/styled(RteNonBreakingSpace, process.env.NODE_ENV === "production" ? {
|
|
31
25
|
target: "e6jub40"
|
|
32
26
|
} : {
|
|
33
27
|
target: "e6jub40",
|
|
@@ -40,4 +34,4 @@ var Icon = /*#__PURE__*/(0, _styles.styled)(_adminIcons.RteNonBreakingSpace, pro
|
|
|
40
34
|
styles: "position:absolute;top:0.12em;left:0.08em;font-size:inherit;color:currentcolor;opacity:0.5/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb3JlL2V4dGVuc2lvbi9Ob25CcmVha2luZ1NwYWNlL0VkaXRvckNvbXBvbmVudC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBeUJ3QyIsImZpbGUiOiIuLi8uLi8uLi8uLi9zcmMvY29yZS9leHRlbnNpb24vTm9uQnJlYWtpbmdTcGFjZS9FZGl0b3JDb21wb25lbnQudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgUnRlTm9uQnJlYWtpbmdTcGFjZSB9IGZyb20gXCJAY29tZXQvYWRtaW4taWNvbnNcIjtcbmltcG9ydCB7IHN0eWxlZCB9IGZyb20gXCJAbXVpL21hdGVyaWFsL3N0eWxlc1wiO1xuaW1wb3J0IHsgdHlwZSBDb250ZW50U3RhdGUgfSBmcm9tIFwiZHJhZnQtanNcIjtcbmltcG9ydCB7IHR5cGUgUHJvcHNXaXRoQ2hpbGRyZW4gfSBmcm9tIFwicmVhY3RcIjtcblxuaW50ZXJmYWNlIFByb3BzIHtcbiAgICBjb250ZW50U3RhdGU6IENvbnRlbnRTdGF0ZTtcbiAgICBlbnRpdHlLZXk6IHN0cmluZztcbn1cblxuY29uc3QgRWRpdG9yQ29tcG9uZW50ID0gKHsgY2hpbGRyZW4gfTogUHJvcHNXaXRoQ2hpbGRyZW48UHJvcHM+KSA9PiB7XG4gICAgcmV0dXJuIChcbiAgICAgICAgPFJvb3Q+XG4gICAgICAgICAgICA8SWNvbiAvPlxuICAgICAgICAgICAge2NoaWxkcmVufVxuICAgICAgICA8L1Jvb3Q+XG4gICAgKTtcbn07XG5cbmNvbnN0IFJvb3QgPSBzdHlsZWQoXCJzcGFuXCIpYFxuICAgIHBvc2l0aW9uOiByZWxhdGl2ZTtcbiAgICAvLyBBcmJpdHJhcnkgdmFsdWUgdG8gbWFrZSB0aGUgbm9uLWJyZWFraW5nIHNwYWNlIHRoZSBzYW1lIHdpZHRoIGFzIHRoZSBpY29uXG4gICAgbGV0dGVyLXNwYWNpbmc6IDAuOWVtO1xuYDtcblxuY29uc3QgSWNvbiA9IHN0eWxlZChSdGVOb25CcmVha2luZ1NwYWNlKWBcbiAgICBwb3NpdGlvbjogYWJzb2x1dGU7XG4gICAgLy8gQXJiaXRyYXJ5IHZhbHVlcyB0byBtYWtlIHRoZSBpY29uIGxvb2sgY2VudGVyZWRcbiAgICB0b3A6IDAuMTJlbTtcbiAgICBsZWZ0OiAwLjA4ZW07XG4gICAgZm9udC1zaXplOiBpbmhlcml0O1xuICAgIGNvbG9yOiBjdXJyZW50Y29sb3I7XG4gICAgb3BhY2l0eTogMC41O1xuYDtcblxuZXhwb3J0IGRlZmF1bHQgRWRpdG9yQ29tcG9uZW50O1xuIl19 */",
|
|
41
35
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
42
36
|
});
|
|
43
|
-
|
|
37
|
+
export default EditorComponent;
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _adminIcons = require("@comet/admin-icons");
|
|
8
|
-
var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
|
|
9
|
-
var _draftJs = require("draft-js");
|
|
10
|
-
var _reactIntl = require("react-intl");
|
|
11
|
-
var _ControlButton = require("../../Controls/ControlButton");
|
|
12
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
1
|
+
import { RteNonBreakingSpace } from "@comet/admin-icons";
|
|
14
2
|
// eslint-disable-next-line no-restricted-imports
|
|
15
|
-
|
|
3
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
4
|
+
import { EditorState, Modifier } from "draft-js";
|
|
5
|
+
import { FormattedMessage } from "react-intl";
|
|
6
|
+
import { ControlButton } from "../../Controls/ControlButton";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
8
|
var NO_BREAK_SPACE_UNICODE_CHAR = 0x00a0;
|
|
17
9
|
function ToolbarButton(_ref) {
|
|
18
10
|
var editorState = _ref.editorState,
|
|
@@ -27,24 +19,24 @@ function ToolbarButton(_ref) {
|
|
|
27
19
|
// works as expected when \u00ad is copied and pasted: https://unicode.flopp.net/c/00A0
|
|
28
20
|
var textWithEntity;
|
|
29
21
|
if (selection.isCollapsed()) {
|
|
30
|
-
textWithEntity =
|
|
22
|
+
textWithEntity = Modifier.insertText(currentContent, selection, String.fromCharCode(NO_BREAK_SPACE_UNICODE_CHAR));
|
|
31
23
|
} else {
|
|
32
|
-
textWithEntity =
|
|
24
|
+
textWithEntity = Modifier.replaceText(currentContent, selection, String.fromCharCode(NO_BREAK_SPACE_UNICODE_CHAR));
|
|
33
25
|
}
|
|
34
|
-
setEditorState(
|
|
26
|
+
setEditorState(EditorState.push(editorState, textWithEntity, "insert-characters"));
|
|
35
27
|
}
|
|
36
|
-
return /*#__PURE__*/(
|
|
37
|
-
title: /*#__PURE__*/(
|
|
28
|
+
return /*#__PURE__*/_jsx(Tooltip, {
|
|
29
|
+
title: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
38
30
|
id: "comet.rte.extensions.nonBreakingSpace.buttonTooltip",
|
|
39
31
|
defaultMessage: "Insert a non-breaking space"
|
|
40
32
|
}),
|
|
41
33
|
placement: "top",
|
|
42
|
-
children: /*#__PURE__*/(
|
|
43
|
-
children: /*#__PURE__*/(
|
|
44
|
-
icon:
|
|
34
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
35
|
+
children: /*#__PURE__*/_jsx(ControlButton, {
|
|
36
|
+
icon: RteNonBreakingSpace,
|
|
45
37
|
onButtonClick: handleClick
|
|
46
38
|
})
|
|
47
39
|
})
|
|
48
40
|
});
|
|
49
41
|
}
|
|
50
|
-
|
|
42
|
+
export default ToolbarButton;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _EditorComponent = require("./EditorComponent");
|
|
1
|
+
import { EditorComponent } from "./EditorComponent";
|
|
8
2
|
var SHY_UNICHAR_REGEX = /\u00ad/g;
|
|
9
3
|
var Decorator = {
|
|
10
4
|
strategy: function strategy(contentBlock, callback) {
|
|
11
5
|
findWithRegex(SHY_UNICHAR_REGEX, contentBlock, callback);
|
|
12
6
|
},
|
|
13
|
-
component:
|
|
7
|
+
component: EditorComponent
|
|
14
8
|
};
|
|
15
9
|
function findWithRegex(regex, contentBlock, callback) {
|
|
16
10
|
var text = contentBlock.getText();
|
|
@@ -20,4 +14,4 @@ function findWithRegex(regex, contentBlock, callback) {
|
|
|
20
14
|
callback(start, start + matchArr[0].length);
|
|
21
15
|
}
|
|
22
16
|
}
|
|
23
|
-
|
|
17
|
+
export default Decorator;
|