@contentful/field-editor-rich-text 2.0.0-next.7 → 2.0.0-next.8
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/dist/field-editor-rich-text.cjs.development.js +58 -47
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +59 -48
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/helpers/editor.d.ts +1 -0
- package/dist/helpers/environment.d.ts +1 -0
- package/package.json +1 -1
- package/CHANGELOG.md +0 -410
|
@@ -491,6 +491,18 @@ function getParents(el) {
|
|
|
491
491
|
return parents;
|
|
492
492
|
}
|
|
493
493
|
|
|
494
|
+
// "modern" Edge was released at 79.x
|
|
495
|
+
var IS_EDGE_LEGACY = typeof navigator !== 'undefined' && /*#__PURE__*/ /Edge?\/(?:[0-6][0-9]|[0-7][0-8])/i.test(navigator.userAgent); // Native `beforeInput` events don't work well with react on Chrome 75
|
|
496
|
+
// and older, Chrome 76+ can use `beforeInput` though.
|
|
497
|
+
|
|
498
|
+
var IS_CHROME_LEGACY = typeof navigator !== 'undefined' && /*#__PURE__*/ /Chrome?\/(?:[0-7][0-5]|[0-6][0-9])/i.test(navigator.userAgent); // COMPAT: Firefox/Edge Legacy don't support the `beforeinput` event
|
|
499
|
+
// Chrome Legacy doesn't support `beforeinput` correctly
|
|
500
|
+
|
|
501
|
+
var HAS_BEFORE_INPUT_SUPPORT = !IS_CHROME_LEGACY && !IS_EDGE_LEGACY && // globalThis is undefined in older browsers
|
|
502
|
+
typeof globalThis !== 'undefined' && globalThis.InputEvent && typeof globalThis.InputEvent.prototype.getTargetRanges === 'function'; // The `getTargetRanges` property isn't recognized.
|
|
503
|
+
|
|
504
|
+
var IS_SAFARI = typeof navigator !== 'undefined' && /*#__PURE__*/ /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
|
|
505
|
+
|
|
494
506
|
var LINK_TYPES = [Contentful.INLINES.HYPERLINK, Contentful.INLINES.ENTRY_HYPERLINK, Contentful.INLINES.ASSET_HYPERLINK];
|
|
495
507
|
function isBlockSelected(editor, type) {
|
|
496
508
|
var _Array$from = Array.from(slate.Editor.nodes(editor, {
|
|
@@ -708,6 +720,17 @@ var isInlineOrText = function isInlineOrText(node) {
|
|
|
708
720
|
// either text or inline elements
|
|
709
721
|
return slate.Text.isText(node) || slate.Element.isElement(node) && INLINE_TYPES.includes(node.type);
|
|
710
722
|
};
|
|
723
|
+
var focus = function focus(editor) {
|
|
724
|
+
var x = window.scrollX;
|
|
725
|
+
var y = window.scrollY;
|
|
726
|
+
Slate.ReactEditor.focus(editor); // Safari has issues with `editor.focus({ preventScroll: true })`, it ignores the option `preventScroll`
|
|
727
|
+
|
|
728
|
+
if (IS_SAFARI) {
|
|
729
|
+
setTimeout(function () {
|
|
730
|
+
window.scrollTo(x, y); // restore position
|
|
731
|
+
}, 0);
|
|
732
|
+
}
|
|
733
|
+
};
|
|
711
734
|
|
|
712
735
|
function withLinkTracking(tracking, Component) {
|
|
713
736
|
return function ComponentWithTracking(props) {
|
|
@@ -719,16 +742,6 @@ function withLinkTracking(tracking, Component) {
|
|
|
719
742
|
};
|
|
720
743
|
}
|
|
721
744
|
|
|
722
|
-
// "modern" Edge was released at 79.x
|
|
723
|
-
var IS_EDGE_LEGACY = typeof navigator !== 'undefined' && /*#__PURE__*/ /Edge?\/(?:[0-6][0-9]|[0-7][0-8])/i.test(navigator.userAgent); // Native `beforeInput` events don't work well with react on Chrome 75
|
|
724
|
-
// and older, Chrome 76+ can use `beforeInput` though.
|
|
725
|
-
|
|
726
|
-
var IS_CHROME_LEGACY = typeof navigator !== 'undefined' && /*#__PURE__*/ /Chrome?\/(?:[0-7][0-5]|[0-6][0-9])/i.test(navigator.userAgent); // COMPAT: Firefox/Edge Legacy don't support the `beforeinput` event
|
|
727
|
-
// Chrome Legacy doesn't support `beforeinput` correctly
|
|
728
|
-
|
|
729
|
-
var HAS_BEFORE_INPUT_SUPPORT = !IS_CHROME_LEGACY && !IS_EDGE_LEGACY && // globalThis is undefined in older browsers
|
|
730
|
-
typeof globalThis !== 'undefined' && globalThis.InputEvent && typeof globalThis.InputEvent.prototype.getTargetRanges === 'function'; // The `getTargetRanges` property isn't recognized.
|
|
731
|
-
|
|
732
745
|
function useSdk(_ref) {
|
|
733
746
|
var sdk = _ref.sdk;
|
|
734
747
|
var sdkMemo = React.useMemo(function () {
|
|
@@ -1107,7 +1120,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
1107
1120
|
|
|
1108
1121
|
var styles$3 = {
|
|
1109
1122
|
root: /*#__PURE__*/emotion.css({
|
|
1110
|
-
marginBottom: '1.25rem'
|
|
1123
|
+
marginBottom: '1.25rem !important'
|
|
1111
1124
|
})
|
|
1112
1125
|
};
|
|
1113
1126
|
function LinkedEntityBlock(props) {
|
|
@@ -1267,9 +1280,11 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
1267
1280
|
|
|
1268
1281
|
|
|
1269
1282
|
var IteratorPrototype = {};
|
|
1270
|
-
|
|
1283
|
+
|
|
1284
|
+
IteratorPrototype[iteratorSymbol] = function () {
|
|
1271
1285
|
return this;
|
|
1272
|
-
}
|
|
1286
|
+
};
|
|
1287
|
+
|
|
1273
1288
|
var getProto = Object.getPrototypeOf;
|
|
1274
1289
|
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
1275
1290
|
|
|
@@ -1280,9 +1295,8 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
1280
1295
|
}
|
|
1281
1296
|
|
|
1282
1297
|
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
1283
|
-
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
1284
|
-
|
|
1285
|
-
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
1298
|
+
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
|
1299
|
+
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
|
1286
1300
|
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
|
|
1287
1301
|
// Iterator interface in terms of a single ._invoke method.
|
|
1288
1302
|
|
|
@@ -1387,9 +1401,11 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
1387
1401
|
}
|
|
1388
1402
|
|
|
1389
1403
|
defineIteratorMethods(AsyncIterator.prototype);
|
|
1390
|
-
|
|
1404
|
+
|
|
1405
|
+
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
|
1391
1406
|
return this;
|
|
1392
|
-
}
|
|
1407
|
+
};
|
|
1408
|
+
|
|
1393
1409
|
exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
|
|
1394
1410
|
// AsyncIterator objects; they just return a Promise for the value of
|
|
1395
1411
|
// the final result produced by the iterator.
|
|
@@ -1566,12 +1582,13 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
1566
1582
|
// object to not be returned from this call. This ensures that doesn't happen.
|
|
1567
1583
|
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
1568
1584
|
|
|
1569
|
-
|
|
1585
|
+
Gp[iteratorSymbol] = function () {
|
|
1570
1586
|
return this;
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1587
|
+
};
|
|
1588
|
+
|
|
1589
|
+
Gp.toString = function () {
|
|
1573
1590
|
return "[object Generator]";
|
|
1574
|
-
}
|
|
1591
|
+
};
|
|
1575
1592
|
|
|
1576
1593
|
function pushTryEntry(locs) {
|
|
1577
1594
|
var entry = {
|
|
@@ -1883,19 +1900,14 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
1883
1900
|
} catch (accidentalStrictMode) {
|
|
1884
1901
|
// This module should not be running in strict mode, so the above
|
|
1885
1902
|
// assignment should always work unless something is misconfigured. Just
|
|
1886
|
-
// in case runtime.js accidentally runs in strict mode,
|
|
1887
|
-
// we can explicitly access globalThis. In older engines we can escape
|
|
1903
|
+
// in case runtime.js accidentally runs in strict mode, we can escape
|
|
1888
1904
|
// strict mode using a global Function call. This could conceivably fail
|
|
1889
1905
|
// if a Content Security Policy forbids using Function, but in that case
|
|
1890
1906
|
// the proper solution is to fix the accidental strict mode problem. If
|
|
1891
1907
|
// you've misconfigured your bundler to force strict mode and applied a
|
|
1892
1908
|
// CSP to forbid Function, and you're not willing to fix either of those
|
|
1893
1909
|
// problems, please detail your unique predicament in a GitHub issue.
|
|
1894
|
-
|
|
1895
|
-
globalThis.regeneratorRuntime = runtime;
|
|
1896
|
-
} else {
|
|
1897
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
1898
|
-
}
|
|
1910
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
1899
1911
|
}
|
|
1900
1912
|
});
|
|
1901
1913
|
|
|
@@ -2071,7 +2083,7 @@ function insertBlock(editor, nodeType, entity) {
|
|
|
2071
2083
|
slate.Transforms.setNodes(editor, linkedEntityBlock);
|
|
2072
2084
|
}
|
|
2073
2085
|
|
|
2074
|
-
|
|
2086
|
+
focus(editor);
|
|
2075
2087
|
}
|
|
2076
2088
|
|
|
2077
2089
|
var styles$4 = {
|
|
@@ -2409,7 +2421,7 @@ function _selectEntityAndInsert$1() {
|
|
|
2409
2421
|
|
|
2410
2422
|
case 4:
|
|
2411
2423
|
entry = _context2.sent;
|
|
2412
|
-
|
|
2424
|
+
focus(editor); // Dialog steals focus from editor, return it.
|
|
2413
2425
|
|
|
2414
2426
|
if (entry) {
|
|
2415
2427
|
_context2.next = 8;
|
|
@@ -2627,7 +2639,7 @@ function ToolbarHeadingButton(props) {
|
|
|
2627
2639
|
position.*/
|
|
2628
2640
|
|
|
2629
2641
|
editor.onChange = function () {
|
|
2630
|
-
|
|
2642
|
+
focus(editor);
|
|
2631
2643
|
editor.onChange = prevOnChange;
|
|
2632
2644
|
prevOnChange.apply(void 0, arguments);
|
|
2633
2645
|
};
|
|
@@ -2922,7 +2934,7 @@ function ToolbarHrButton(props) {
|
|
|
2922
2934
|
hasText ? slate.Transforms.insertNodes(editor, hr) : plateCore.setNodes(editor, hr); // Move focus to the next paragraph (added by TrailingParagraph plugin)
|
|
2923
2935
|
|
|
2924
2936
|
moveToTheNextLine(editor);
|
|
2925
|
-
|
|
2937
|
+
focus(editor);
|
|
2926
2938
|
}
|
|
2927
2939
|
|
|
2928
2940
|
if (!editor) return null;
|
|
@@ -3414,7 +3426,7 @@ function _addOrEditLink() {
|
|
|
3414
3426
|
path: path
|
|
3415
3427
|
});
|
|
3416
3428
|
});
|
|
3417
|
-
|
|
3429
|
+
focus(editor);
|
|
3418
3430
|
|
|
3419
3431
|
case 15:
|
|
3420
3432
|
case "end":
|
|
@@ -4168,7 +4180,7 @@ function ToolbarListButton(props) {
|
|
|
4168
4180
|
plateList.toggleList(editor, {
|
|
4169
4181
|
type: type
|
|
4170
4182
|
});
|
|
4171
|
-
|
|
4183
|
+
focus(editor);
|
|
4172
4184
|
};
|
|
4173
4185
|
}
|
|
4174
4186
|
|
|
@@ -4196,7 +4208,7 @@ function ToolbarBoldButton(props) {
|
|
|
4196
4208
|
plateCore.toggleMark(editor, {
|
|
4197
4209
|
key: Contentful.MARKS.BOLD
|
|
4198
4210
|
});
|
|
4199
|
-
|
|
4211
|
+
focus(editor);
|
|
4200
4212
|
}
|
|
4201
4213
|
|
|
4202
4214
|
if (!editor) return null;
|
|
@@ -4255,7 +4267,7 @@ function ToolbarCodeButton(props) {
|
|
|
4255
4267
|
plateCore.toggleMark(editor, {
|
|
4256
4268
|
key: Contentful.MARKS.CODE
|
|
4257
4269
|
});
|
|
4258
|
-
|
|
4270
|
+
focus(editor);
|
|
4259
4271
|
}
|
|
4260
4272
|
|
|
4261
4273
|
if (!editor) return null;
|
|
@@ -4305,7 +4317,7 @@ function ToolbarItalicButton(props) {
|
|
|
4305
4317
|
plateCore.toggleMark(editor, {
|
|
4306
4318
|
key: Contentful.MARKS.ITALIC
|
|
4307
4319
|
});
|
|
4308
|
-
|
|
4320
|
+
focus(editor);
|
|
4309
4321
|
}
|
|
4310
4322
|
|
|
4311
4323
|
if (!editor) return null;
|
|
@@ -4359,7 +4371,7 @@ function ToolbarUnderlineButton(props) {
|
|
|
4359
4371
|
plateCore.toggleMark(editor, {
|
|
4360
4372
|
key: Contentful.MARKS.UNDERLINE
|
|
4361
4373
|
});
|
|
4362
|
-
|
|
4374
|
+
focus(editor);
|
|
4363
4375
|
}
|
|
4364
4376
|
|
|
4365
4377
|
if (!editor) return null;
|
|
@@ -4844,7 +4856,7 @@ function ToolbarQuoteButton(props) {
|
|
|
4844
4856
|
function handleOnClick() {
|
|
4845
4857
|
if (!editor) return;
|
|
4846
4858
|
toggleQuote(editor);
|
|
4847
|
-
|
|
4859
|
+
focus(editor);
|
|
4848
4860
|
}
|
|
4849
4861
|
|
|
4850
4862
|
if (!editor) return null;
|
|
@@ -5200,11 +5212,7 @@ var TableActions = function TableActions() {
|
|
|
5200
5212
|
|
|
5201
5213
|
var close = React__default.useCallback(function () {
|
|
5202
5214
|
setOpen(false);
|
|
5203
|
-
|
|
5204
|
-
// the dropdown menu
|
|
5205
|
-
|
|
5206
|
-
Slate.ReactEditor.focus(editor);
|
|
5207
|
-
}, [editor]);
|
|
5215
|
+
}, []);
|
|
5208
5216
|
React__default.useEffect(function () {
|
|
5209
5217
|
setHeaderEnabled(Boolean(editor && isTableHeaderEnabled(editor)));
|
|
5210
5218
|
}, [editor]);
|
|
@@ -5473,7 +5481,7 @@ function ToolbarTableButton(props) {
|
|
|
5473
5481
|
case 2:
|
|
5474
5482
|
onViewportAction('insertTable');
|
|
5475
5483
|
insertTableAndFocusFirstCell(editor);
|
|
5476
|
-
|
|
5484
|
+
focus(editor);
|
|
5477
5485
|
|
|
5478
5486
|
case 5:
|
|
5479
5487
|
case "end":
|
|
@@ -5617,11 +5625,14 @@ var createVoidsPlugin = function createVoidsPlugin() {
|
|
|
5617
5625
|
}, {
|
|
5618
5626
|
// Inserts a new paragraph on enter when a void element is focused
|
|
5619
5627
|
hotkey: 'enter',
|
|
5628
|
+
// exploit the internal use of Array.slice(0, level + 1) by the exitBreak plugin
|
|
5629
|
+
// to stay in the parent element
|
|
5630
|
+
level: -2,
|
|
5620
5631
|
query: {
|
|
5621
5632
|
filter: function filter(_ref2) {
|
|
5622
5633
|
var node = _ref2[0],
|
|
5623
5634
|
path = _ref2[1];
|
|
5624
|
-
return !plateCore.isFirstChild(path) && !!node.isVoid;
|
|
5635
|
+
return !(isRootLevel(path) && plateCore.isFirstChild(path)) && !!node.isVoid;
|
|
5625
5636
|
}
|
|
5626
5637
|
}
|
|
5627
5638
|
}],
|