@commercetools-uikit/rich-text-utils 16.2.0 → 16.2.1
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.
|
@@ -211,6 +211,12 @@ const TEXT_TAGS = {
|
|
|
211
211
|
S: () => ({
|
|
212
212
|
strikethrough: true
|
|
213
213
|
}),
|
|
214
|
+
SUP: () => ({
|
|
215
|
+
superscript: true
|
|
216
|
+
}),
|
|
217
|
+
SUB: () => ({
|
|
218
|
+
subscript: true
|
|
219
|
+
}),
|
|
214
220
|
STRONG: () => ({
|
|
215
221
|
bold: true
|
|
216
222
|
}),
|
|
@@ -329,9 +335,7 @@ const deserializeElement = el => {
|
|
|
329
335
|
const attrs = TEXT_TAGS[nodeName]();
|
|
330
336
|
return _mapInstanceProperty__default["default"](children).call(children, child => slateHyperscript.jsx('text', attrs, child));
|
|
331
337
|
}
|
|
332
|
-
|
|
333
|
-
// each non-empty text node must be wrapped with a paragraph
|
|
334
|
-
return _mapInstanceProperty__default["default"](children).call(children, child => slate.Text.isText(child) && child.text ? wrapWithParagraph(child) : child);
|
|
338
|
+
return children;
|
|
335
339
|
};
|
|
336
340
|
const deserialize = html => {
|
|
337
341
|
const document = new DOMParser().parseFromString(html || '<p></p>', 'text/html');
|
|
@@ -2377,7 +2381,7 @@ var messages = reactIntl.defineMessages({
|
|
|
2377
2381
|
});
|
|
2378
2382
|
|
|
2379
2383
|
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2380
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
2384
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$1(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
2381
2385
|
const LIST_TYPES = [BLOCK_TAGS.ol, BLOCK_TAGS.ul];
|
|
2382
2386
|
|
|
2383
2387
|
/*
|
|
@@ -2564,28 +2568,38 @@ const toggleBlock = (editor, format) => {
|
|
|
2564
2568
|
slate.Transforms.wrapNodes(editor, block);
|
|
2565
2569
|
}
|
|
2566
2570
|
};
|
|
2571
|
+
function nonNullable(value) {
|
|
2572
|
+
return value !== null && value !== undefined;
|
|
2573
|
+
}
|
|
2567
2574
|
const validSlateStateAdapter = value => {
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2575
|
+
const valueAsArray = _Array$isArray__default["default"](value) ? value : [value];
|
|
2576
|
+
if (slate.Element.isElementList(value) || slate.Text.isTextList(value) ||
|
|
2577
|
+
// in case of an array of mixed text and element nodes
|
|
2578
|
+
_Array$isArray__default["default"](value) && _everyInstanceProperty__default["default"](value).call(value, node => slate.Element.isElement(node) || slate.Text.isText(node))) {
|
|
2579
|
+
var _context;
|
|
2580
|
+
return _filterInstanceProperty__default["default"](_context = _mapInstanceProperty__default["default"](valueAsArray).call(valueAsArray, node => slate.Text.isText(node) ? {
|
|
2581
|
+
type: 'text',
|
|
2582
|
+
children: [node]
|
|
2583
|
+
} : node)).call(_context, nonNullable);
|
|
2573
2584
|
}
|
|
2574
2585
|
return defaultSlateState;
|
|
2575
2586
|
};
|
|
2576
2587
|
const resetEditor = (editor, resetValue) => {
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
})
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
node: newState[0]
|
|
2588
|
+
slate.Transforms.delete(editor, {
|
|
2589
|
+
at: {
|
|
2590
|
+
anchor: slate.Editor.start(editor, []),
|
|
2591
|
+
focus: slate.Editor.end(editor, [])
|
|
2592
|
+
}
|
|
2593
|
+
});
|
|
2594
|
+
|
|
2595
|
+
// remove empty node
|
|
2596
|
+
slate.Transforms.removeNodes(editor, {
|
|
2597
|
+
at: [0]
|
|
2588
2598
|
});
|
|
2599
|
+
const newState = resetValue ? validSlateStateAdapter(html$1.deserialize(resetValue)) : defaultSlateState;
|
|
2600
|
+
|
|
2601
|
+
// insert all new nodes
|
|
2602
|
+
slate.Transforms.insertNodes(editor, newState);
|
|
2589
2603
|
};
|
|
2590
2604
|
const focusEditor = editor => {
|
|
2591
2605
|
slateReact.ReactEditor.focus(editor);
|
|
@@ -2980,7 +2994,7 @@ RichTextEditorBody.defaultProps = defaultProps;
|
|
|
2980
2994
|
var RichTextEditorBody$1 = RichTextEditorBody;
|
|
2981
2995
|
|
|
2982
2996
|
// NOTE: This string will be replaced on build time with the package version.
|
|
2983
|
-
var version = "16.2.
|
|
2997
|
+
var version = "16.2.1";
|
|
2984
2998
|
|
|
2985
2999
|
exports.Element = Element;
|
|
2986
3000
|
exports.HiddenInput = HiddenInput$1;
|
|
@@ -210,6 +210,12 @@ const TEXT_TAGS = {
|
|
|
210
210
|
S: () => ({
|
|
211
211
|
strikethrough: true
|
|
212
212
|
}),
|
|
213
|
+
SUP: () => ({
|
|
214
|
+
superscript: true
|
|
215
|
+
}),
|
|
216
|
+
SUB: () => ({
|
|
217
|
+
subscript: true
|
|
218
|
+
}),
|
|
213
219
|
STRONG: () => ({
|
|
214
220
|
bold: true
|
|
215
221
|
}),
|
|
@@ -328,9 +334,7 @@ const deserializeElement = el => {
|
|
|
328
334
|
const attrs = TEXT_TAGS[nodeName]();
|
|
329
335
|
return _mapInstanceProperty__default["default"](children).call(children, child => slateHyperscript.jsx('text', attrs, child));
|
|
330
336
|
}
|
|
331
|
-
|
|
332
|
-
// each non-empty text node must be wrapped with a paragraph
|
|
333
|
-
return _mapInstanceProperty__default["default"](children).call(children, child => slate.Text.isText(child) && child.text ? wrapWithParagraph(child) : child);
|
|
337
|
+
return children;
|
|
334
338
|
};
|
|
335
339
|
const deserialize = html => {
|
|
336
340
|
const document = new DOMParser().parseFromString(html || '<p></p>', 'text/html');
|
|
@@ -2180,7 +2184,7 @@ var messages = reactIntl.defineMessages({
|
|
|
2180
2184
|
});
|
|
2181
2185
|
|
|
2182
2186
|
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2183
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
2187
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$1(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
2184
2188
|
const LIST_TYPES = [BLOCK_TAGS.ol, BLOCK_TAGS.ul];
|
|
2185
2189
|
|
|
2186
2190
|
/*
|
|
@@ -2367,28 +2371,38 @@ const toggleBlock = (editor, format) => {
|
|
|
2367
2371
|
slate.Transforms.wrapNodes(editor, block);
|
|
2368
2372
|
}
|
|
2369
2373
|
};
|
|
2374
|
+
function nonNullable(value) {
|
|
2375
|
+
return value !== null && value !== undefined;
|
|
2376
|
+
}
|
|
2370
2377
|
const validSlateStateAdapter = value => {
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2378
|
+
const valueAsArray = _Array$isArray__default["default"](value) ? value : [value];
|
|
2379
|
+
if (slate.Element.isElementList(value) || slate.Text.isTextList(value) ||
|
|
2380
|
+
// in case of an array of mixed text and element nodes
|
|
2381
|
+
_Array$isArray__default["default"](value) && _everyInstanceProperty__default["default"](value).call(value, node => slate.Element.isElement(node) || slate.Text.isText(node))) {
|
|
2382
|
+
var _context;
|
|
2383
|
+
return _filterInstanceProperty__default["default"](_context = _mapInstanceProperty__default["default"](valueAsArray).call(valueAsArray, node => slate.Text.isText(node) ? {
|
|
2384
|
+
type: 'text',
|
|
2385
|
+
children: [node]
|
|
2386
|
+
} : node)).call(_context, nonNullable);
|
|
2376
2387
|
}
|
|
2377
2388
|
return defaultSlateState;
|
|
2378
2389
|
};
|
|
2379
2390
|
const resetEditor = (editor, resetValue) => {
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
})
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
node: newState[0]
|
|
2391
|
+
slate.Transforms.delete(editor, {
|
|
2392
|
+
at: {
|
|
2393
|
+
anchor: slate.Editor.start(editor, []),
|
|
2394
|
+
focus: slate.Editor.end(editor, [])
|
|
2395
|
+
}
|
|
2396
|
+
});
|
|
2397
|
+
|
|
2398
|
+
// remove empty node
|
|
2399
|
+
slate.Transforms.removeNodes(editor, {
|
|
2400
|
+
at: [0]
|
|
2391
2401
|
});
|
|
2402
|
+
const newState = resetValue ? validSlateStateAdapter(html$1.deserialize(resetValue)) : defaultSlateState;
|
|
2403
|
+
|
|
2404
|
+
// insert all new nodes
|
|
2405
|
+
slate.Transforms.insertNodes(editor, newState);
|
|
2392
2406
|
};
|
|
2393
2407
|
const focusEditor = editor => {
|
|
2394
2408
|
slateReact.ReactEditor.focus(editor);
|
|
@@ -2748,7 +2762,7 @@ RichTextEditorBody.defaultProps = defaultProps;
|
|
|
2748
2762
|
var RichTextEditorBody$1 = RichTextEditorBody;
|
|
2749
2763
|
|
|
2750
2764
|
// NOTE: This string will be replaced on build time with the package version.
|
|
2751
|
-
var version = "16.2.
|
|
2765
|
+
var version = "16.2.1";
|
|
2752
2766
|
|
|
2753
2767
|
exports.Element = Element;
|
|
2754
2768
|
exports.HiddenInput = HiddenInput$1;
|
|
@@ -174,6 +174,12 @@ const TEXT_TAGS = {
|
|
|
174
174
|
S: () => ({
|
|
175
175
|
strikethrough: true
|
|
176
176
|
}),
|
|
177
|
+
SUP: () => ({
|
|
178
|
+
superscript: true
|
|
179
|
+
}),
|
|
180
|
+
SUB: () => ({
|
|
181
|
+
subscript: true
|
|
182
|
+
}),
|
|
177
183
|
STRONG: () => ({
|
|
178
184
|
bold: true
|
|
179
185
|
}),
|
|
@@ -292,9 +298,7 @@ const deserializeElement = el => {
|
|
|
292
298
|
const attrs = TEXT_TAGS[nodeName]();
|
|
293
299
|
return _mapInstanceProperty(children).call(children, child => jsx('text', attrs, child));
|
|
294
300
|
}
|
|
295
|
-
|
|
296
|
-
// each non-empty text node must be wrapped with a paragraph
|
|
297
|
-
return _mapInstanceProperty(children).call(children, child => Text.isText(child) && child.text ? wrapWithParagraph(child) : child);
|
|
301
|
+
return children;
|
|
298
302
|
};
|
|
299
303
|
const deserialize = html => {
|
|
300
304
|
const document = new DOMParser().parseFromString(html || '<p></p>', 'text/html');
|
|
@@ -2340,7 +2344,7 @@ var messages = defineMessages({
|
|
|
2340
2344
|
});
|
|
2341
2345
|
|
|
2342
2346
|
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2343
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
2347
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys$1(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys$1(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2344
2348
|
const LIST_TYPES = [BLOCK_TAGS.ol, BLOCK_TAGS.ul];
|
|
2345
2349
|
|
|
2346
2350
|
/*
|
|
@@ -2527,28 +2531,38 @@ const toggleBlock = (editor, format) => {
|
|
|
2527
2531
|
Transforms.wrapNodes(editor, block);
|
|
2528
2532
|
}
|
|
2529
2533
|
};
|
|
2534
|
+
function nonNullable(value) {
|
|
2535
|
+
return value !== null && value !== undefined;
|
|
2536
|
+
}
|
|
2530
2537
|
const validSlateStateAdapter = value => {
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2538
|
+
const valueAsArray = _Array$isArray(value) ? value : [value];
|
|
2539
|
+
if (Element$1.isElementList(value) || Text.isTextList(value) ||
|
|
2540
|
+
// in case of an array of mixed text and element nodes
|
|
2541
|
+
_Array$isArray(value) && _everyInstanceProperty(value).call(value, node => Element$1.isElement(node) || Text.isText(node))) {
|
|
2542
|
+
var _context;
|
|
2543
|
+
return _filterInstanceProperty(_context = _mapInstanceProperty(valueAsArray).call(valueAsArray, node => Text.isText(node) ? {
|
|
2544
|
+
type: 'text',
|
|
2545
|
+
children: [node]
|
|
2546
|
+
} : node)).call(_context, nonNullable);
|
|
2536
2547
|
}
|
|
2537
2548
|
return defaultSlateState;
|
|
2538
2549
|
};
|
|
2539
2550
|
const resetEditor = (editor, resetValue) => {
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
})
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
node: newState[0]
|
|
2551
|
+
Transforms.delete(editor, {
|
|
2552
|
+
at: {
|
|
2553
|
+
anchor: Editor.start(editor, []),
|
|
2554
|
+
focus: Editor.end(editor, [])
|
|
2555
|
+
}
|
|
2556
|
+
});
|
|
2557
|
+
|
|
2558
|
+
// remove empty node
|
|
2559
|
+
Transforms.removeNodes(editor, {
|
|
2560
|
+
at: [0]
|
|
2551
2561
|
});
|
|
2562
|
+
const newState = resetValue ? validSlateStateAdapter(html$1.deserialize(resetValue)) : defaultSlateState;
|
|
2563
|
+
|
|
2564
|
+
// insert all new nodes
|
|
2565
|
+
Transforms.insertNodes(editor, newState);
|
|
2552
2566
|
};
|
|
2553
2567
|
const focusEditor = editor => {
|
|
2554
2568
|
ReactEditor.focus(editor);
|
|
@@ -2943,6 +2957,6 @@ RichTextEditorBody.defaultProps = defaultProps;
|
|
|
2943
2957
|
var RichTextEditorBody$1 = RichTextEditorBody;
|
|
2944
2958
|
|
|
2945
2959
|
// NOTE: This string will be replaced on build time with the package version.
|
|
2946
|
-
var version = "16.2.
|
|
2960
|
+
var version = "16.2.1";
|
|
2947
2961
|
|
|
2948
2962
|
export { Element, HiddenInput$1 as HiddenInput, Leaf, RichTextEditorBody$1 as RichTextBody, focusEditor, html$1 as html, isBlockActive, isRichTextEmpty as isEmpty, isMarkActive, index as localized, resetEditor, toggleBlock, toggleMark, validSlateStateAdapter, version };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/rich-text-utils",
|
|
3
3
|
"description": "Utilities for working with rich-text components.",
|
|
4
|
-
"version": "16.2.
|
|
4
|
+
"version": "16.2.1",
|
|
5
5
|
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@babel/runtime": "^7.20.13",
|
|
26
26
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
27
|
-
"@commercetools-uikit/design-system": "16.2.
|
|
28
|
-
"@commercetools-uikit/icons": "16.2.
|
|
29
|
-
"@commercetools-uikit/input-utils": "16.2.
|
|
30
|
-
"@commercetools-uikit/spacings-inline": "16.2.
|
|
31
|
-
"@commercetools-uikit/tooltip": "16.2.
|
|
32
|
-
"@commercetools-uikit/utils": "16.2.
|
|
27
|
+
"@commercetools-uikit/design-system": "16.2.1",
|
|
28
|
+
"@commercetools-uikit/icons": "16.2.1",
|
|
29
|
+
"@commercetools-uikit/input-utils": "16.2.1",
|
|
30
|
+
"@commercetools-uikit/spacings-inline": "16.2.1",
|
|
31
|
+
"@commercetools-uikit/tooltip": "16.2.1",
|
|
32
|
+
"@commercetools-uikit/utils": "16.2.1",
|
|
33
33
|
"@emotion/react": "^11.10.5",
|
|
34
34
|
"@emotion/styled": "^11.10.5",
|
|
35
35
|
"@types/escape-html": "1.0.2",
|