@contentful/field-editor-rich-text 2.0.0-next.15 → 2.0.0-next.18

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.
@@ -254,25 +254,29 @@ function getContentfulEditorId(sdk) {
254
254
  }
255
255
  var editorContext = /*#__PURE__*/React.createContext('');
256
256
  var ContentfulEditorIdProvider = editorContext.Provider;
257
- function useContentfulEditorId() {
258
- var id = React.useContext(editorContext);
257
+ function useContentfulEditorId(id) {
258
+ var contextId = React.useContext(editorContext);
259
259
 
260
- if (!id) {
260
+ if (id) {
261
+ return id;
262
+ }
263
+
264
+ if (!contextId) {
261
265
  throw new Error('could not find editor id. Please ensure the component is wrapped in <ContentfulEditorIdProvider> ');
262
266
  }
263
267
 
264
- return id;
268
+ return contextId;
265
269
  } // This hook re-renders when the value changes
266
270
  // Use case: Toolbar icons, for example
267
271
 
268
- function useContentfulEditor() {
269
- var editorId = useContentfulEditorId();
272
+ function useContentfulEditor(id) {
273
+ var editorId = useContentfulEditorId(id);
270
274
  var editor = plateCore.usePlateEditorState(editorId);
271
275
  return editor;
272
276
  } // This doesn't re-render when the value changes
273
277
 
274
- function useContentfulEditorRef() {
275
- var editorId = useContentfulEditorId();
278
+ function useContentfulEditorRef(id) {
279
+ var editorId = useContentfulEditorId(id);
276
280
  var editor = plateCore.usePlateEditorRef(editorId);
277
281
  return editor;
278
282
  }
@@ -539,17 +543,6 @@ function getAncestorPathFromSelection(editor) {
539
543
  return level.length === 1;
540
544
  });
541
545
  }
542
- function shouldUnwrapBlockquote(editor, type) {
543
- var isQuoteSelected = isBlockSelected(editor, Contentful.BLOCKS.QUOTE);
544
- var isValidType = [].concat(Contentful.HEADINGS, [Contentful.BLOCKS.OL_LIST, Contentful.BLOCKS.UL_LIST, Contentful.BLOCKS.HR]).includes(type);
545
- return isQuoteSelected && isValidType;
546
- }
547
- function unwrapFromRoot(editor) {
548
- var ancestorPath = getAncestorPathFromSelection(editor);
549
- slate.Transforms.unwrapNodes(editor, {
550
- at: ancestorPath
551
- });
552
- }
553
546
  var isAtEndOfTextSelection = function isAtEndOfTextSelection(editor) {
554
547
  var _editor$selection, _editor$selection2;
555
548
 
@@ -618,6 +611,13 @@ var focus = function focus(editor) {
618
611
  }, 0);
619
612
  }
620
613
  };
614
+ function toggleElement(editor, options, editorOptions) {
615
+ plateCore.toggleNodeType(editor, options, editorOptions); // We must reset `data` from one element to another
616
+
617
+ slate.Transforms.setNodes(editor, {
618
+ data: {}
619
+ });
620
+ }
621
621
 
622
622
  function withLinkTracking(Component) {
623
623
  return function ComponentWithTracking(props) {
@@ -1076,197 +1076,201 @@ function createCommonjsModule(fn, module) {
1076
1076
  return module = { exports: {} }, fn(module, module.exports), module.exports;
1077
1077
  }
1078
1078
 
1079
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
1080
- /**
1081
- * Copyright (c) 2014-present, Facebook, Inc.
1082
- *
1083
- * This source code is licensed under the MIT license found in the
1084
- * LICENSE file in the root directory of this source tree.
1085
- */
1086
- var runtime = function (exports) {
1087
-
1088
- var Op = Object.prototype;
1089
- var hasOwn = Op.hasOwnProperty;
1090
- var undefined$1; // More compressible than void 0.
1091
-
1092
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
1093
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
1094
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
1095
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
1096
-
1097
- function define(obj, key, value) {
1098
- Object.defineProperty(obj, key, {
1099
- value: value,
1100
- enumerable: true,
1101
- configurable: true,
1102
- writable: true
1103
- });
1104
- return obj[key];
1105
- }
1079
+ var runtime_1 = createCommonjsModule(function (module) {
1080
+ /**
1081
+ * Copyright (c) 2014-present, Facebook, Inc.
1082
+ *
1083
+ * This source code is licensed under the MIT license found in the
1084
+ * LICENSE file in the root directory of this source tree.
1085
+ */
1106
1086
 
1107
- try {
1108
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
1109
- define({}, "");
1110
- } catch (err) {
1111
- define = function define(obj, key, value) {
1112
- return obj[key] = value;
1113
- };
1114
- }
1087
+ var runtime = (function (exports) {
1088
+
1089
+ var Op = Object.prototype;
1090
+ var hasOwn = Op.hasOwnProperty;
1091
+ var undefined$1; // More compressible than void 0.
1092
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
1093
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
1094
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
1095
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
1096
+
1097
+ function define(obj, key, value) {
1098
+ Object.defineProperty(obj, key, {
1099
+ value: value,
1100
+ enumerable: true,
1101
+ configurable: true,
1102
+ writable: true
1103
+ });
1104
+ return obj[key];
1105
+ }
1106
+ try {
1107
+ // IE 8 has a broken Object.defineProperty that only works on DOM objects.
1108
+ define({}, "");
1109
+ } catch (err) {
1110
+ define = function(obj, key, value) {
1111
+ return obj[key] = value;
1112
+ };
1113
+ }
1115
1114
 
1116
- function wrap(innerFn, outerFn, self, tryLocsList) {
1117
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
1118
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
1119
- var generator = Object.create(protoGenerator.prototype);
1120
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
1121
- // .throw, and .return methods.
1115
+ function wrap(innerFn, outerFn, self, tryLocsList) {
1116
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
1117
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
1118
+ var generator = Object.create(protoGenerator.prototype);
1119
+ var context = new Context(tryLocsList || []);
1122
1120
 
1123
- generator._invoke = makeInvokeMethod(innerFn, self, context);
1124
- return generator;
1125
- }
1121
+ // The ._invoke method unifies the implementations of the .next,
1122
+ // .throw, and .return methods.
1123
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
1126
1124
 
1127
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
1128
- // record like context.tryEntries[i].completion. This interface could
1129
- // have been (and was previously) designed to take a closure to be
1130
- // invoked without arguments, but in all the cases we care about we
1131
- // already have an existing method we want to call, so there's no need
1132
- // to create a new function object. We can even get away with assuming
1133
- // the method takes exactly one argument, since that happens to be true
1134
- // in every case, so we don't have to touch the arguments object. The
1135
- // only additional allocation required is the completion record, which
1136
- // has a stable shape and so hopefully should be cheap to allocate.
1137
-
1138
- function tryCatch(fn, obj, arg) {
1139
- try {
1140
- return {
1141
- type: "normal",
1142
- arg: fn.call(obj, arg)
1143
- };
1144
- } catch (err) {
1145
- return {
1146
- type: "throw",
1147
- arg: err
1148
- };
1149
- }
1125
+ return generator;
1126
+ }
1127
+ exports.wrap = wrap;
1128
+
1129
+ // Try/catch helper to minimize deoptimizations. Returns a completion
1130
+ // record like context.tryEntries[i].completion. This interface could
1131
+ // have been (and was previously) designed to take a closure to be
1132
+ // invoked without arguments, but in all the cases we care about we
1133
+ // already have an existing method we want to call, so there's no need
1134
+ // to create a new function object. We can even get away with assuming
1135
+ // the method takes exactly one argument, since that happens to be true
1136
+ // in every case, so we don't have to touch the arguments object. The
1137
+ // only additional allocation required is the completion record, which
1138
+ // has a stable shape and so hopefully should be cheap to allocate.
1139
+ function tryCatch(fn, obj, arg) {
1140
+ try {
1141
+ return { type: "normal", arg: fn.call(obj, arg) };
1142
+ } catch (err) {
1143
+ return { type: "throw", arg: err };
1150
1144
  }
1145
+ }
1151
1146
 
1152
- var GenStateSuspendedStart = "suspendedStart";
1153
- var GenStateSuspendedYield = "suspendedYield";
1154
- var GenStateExecuting = "executing";
1155
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
1156
- // breaking out of the dispatch switch statement.
1157
-
1158
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
1159
- // .constructor.prototype properties for functions that return Generator
1160
- // objects. For full spec compliance, you may wish to configure your
1161
- // minifier not to mangle the names of these two functions.
1162
-
1163
- function Generator() {}
1164
-
1165
- function GeneratorFunction() {}
1166
-
1167
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
1168
- // don't natively support it.
1147
+ var GenStateSuspendedStart = "suspendedStart";
1148
+ var GenStateSuspendedYield = "suspendedYield";
1149
+ var GenStateExecuting = "executing";
1150
+ var GenStateCompleted = "completed";
1151
+
1152
+ // Returning this object from the innerFn has the same effect as
1153
+ // breaking out of the dispatch switch statement.
1154
+ var ContinueSentinel = {};
1155
+
1156
+ // Dummy constructor functions that we use as the .constructor and
1157
+ // .constructor.prototype properties for functions that return Generator
1158
+ // objects. For full spec compliance, you may wish to configure your
1159
+ // minifier not to mangle the names of these two functions.
1160
+ function Generator() {}
1161
+ function GeneratorFunction() {}
1162
+ function GeneratorFunctionPrototype() {}
1163
+
1164
+ // This is a polyfill for %IteratorPrototype% for environments that
1165
+ // don't natively support it.
1166
+ var IteratorPrototype = {};
1167
+ define(IteratorPrototype, iteratorSymbol, function () {
1168
+ return this;
1169
+ });
1169
1170
 
1171
+ var getProto = Object.getPrototypeOf;
1172
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
1173
+ if (NativeIteratorPrototype &&
1174
+ NativeIteratorPrototype !== Op &&
1175
+ hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
1176
+ // This environment has a native %IteratorPrototype%; use it instead
1177
+ // of the polyfill.
1178
+ IteratorPrototype = NativeIteratorPrototype;
1179
+ }
1170
1180
 
1171
- var IteratorPrototype = {};
1172
- define(IteratorPrototype, iteratorSymbol, function () {
1173
- return this;
1181
+ var Gp = GeneratorFunctionPrototype.prototype =
1182
+ Generator.prototype = Object.create(IteratorPrototype);
1183
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
1184
+ define(Gp, "constructor", GeneratorFunctionPrototype);
1185
+ define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
1186
+ GeneratorFunction.displayName = define(
1187
+ GeneratorFunctionPrototype,
1188
+ toStringTagSymbol,
1189
+ "GeneratorFunction"
1190
+ );
1191
+
1192
+ // Helper for defining the .next, .throw, and .return methods of the
1193
+ // Iterator interface in terms of a single ._invoke method.
1194
+ function defineIteratorMethods(prototype) {
1195
+ ["next", "throw", "return"].forEach(function(method) {
1196
+ define(prototype, method, function(arg) {
1197
+ return this._invoke(method, arg);
1198
+ });
1174
1199
  });
1175
- var getProto = Object.getPrototypeOf;
1176
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
1200
+ }
1177
1201
 
1178
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
1179
- // This environment has a native %IteratorPrototype%; use it instead
1180
- // of the polyfill.
1181
- IteratorPrototype = NativeIteratorPrototype;
1182
- }
1202
+ exports.isGeneratorFunction = function(genFun) {
1203
+ var ctor = typeof genFun === "function" && genFun.constructor;
1204
+ return ctor
1205
+ ? ctor === GeneratorFunction ||
1206
+ // For the native GeneratorFunction constructor, the best we can
1207
+ // do is to check its .name property.
1208
+ (ctor.displayName || ctor.name) === "GeneratorFunction"
1209
+ : false;
1210
+ };
1183
1211
 
1184
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
1185
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
1186
- define(Gp, "constructor", GeneratorFunctionPrototype);
1187
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
1188
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
1189
- // Iterator interface in terms of a single ._invoke method.
1190
-
1191
- function defineIteratorMethods(prototype) {
1192
- ["next", "throw", "return"].forEach(function (method) {
1193
- define(prototype, method, function (arg) {
1194
- return this._invoke(method, arg);
1195
- });
1196
- });
1212
+ exports.mark = function(genFun) {
1213
+ if (Object.setPrototypeOf) {
1214
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
1215
+ } else {
1216
+ genFun.__proto__ = GeneratorFunctionPrototype;
1217
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
1197
1218
  }
1219
+ genFun.prototype = Object.create(Gp);
1220
+ return genFun;
1221
+ };
1198
1222
 
1199
- exports.isGeneratorFunction = function (genFun) {
1200
- var ctor = typeof genFun === "function" && genFun.constructor;
1201
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
1202
- // do is to check its .name property.
1203
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
1204
- };
1223
+ // Within the body of any async function, `await x` is transformed to
1224
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
1225
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
1226
+ // meant to be awaited.
1227
+ exports.awrap = function(arg) {
1228
+ return { __await: arg };
1229
+ };
1205
1230
 
1206
- exports.mark = function (genFun) {
1207
- if (Object.setPrototypeOf) {
1208
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
1231
+ function AsyncIterator(generator, PromiseImpl) {
1232
+ function invoke(method, arg, resolve, reject) {
1233
+ var record = tryCatch(generator[method], generator, arg);
1234
+ if (record.type === "throw") {
1235
+ reject(record.arg);
1209
1236
  } else {
1210
- genFun.__proto__ = GeneratorFunctionPrototype;
1211
- define(genFun, toStringTagSymbol, "GeneratorFunction");
1212
- }
1213
-
1214
- genFun.prototype = Object.create(Gp);
1215
- return genFun;
1216
- }; // Within the body of any async function, `await x` is transformed to
1217
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
1218
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
1219
- // meant to be awaited.
1220
-
1221
-
1222
- exports.awrap = function (arg) {
1223
- return {
1224
- __await: arg
1225
- };
1226
- };
1227
-
1228
- function AsyncIterator(generator, PromiseImpl) {
1229
- function invoke(method, arg, resolve, reject) {
1230
- var record = tryCatch(generator[method], generator, arg);
1231
-
1232
- if (record.type === "throw") {
1233
- reject(record.arg);
1234
- } else {
1235
- var result = record.arg;
1236
- var value = result.value;
1237
-
1238
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
1239
- return PromiseImpl.resolve(value.__await).then(function (value) {
1240
- invoke("next", value, resolve, reject);
1241
- }, function (err) {
1242
- invoke("throw", err, resolve, reject);
1243
- });
1244
- }
1245
-
1246
- return PromiseImpl.resolve(value).then(function (unwrapped) {
1247
- // When a yielded Promise is resolved, its final value becomes
1248
- // the .value of the Promise<{value,done}> result for the
1249
- // current iteration.
1250
- result.value = unwrapped;
1251
- resolve(result);
1252
- }, function (error) {
1253
- // If a rejected Promise was yielded, throw the rejection back
1254
- // into the async generator function so it can be handled there.
1255
- return invoke("throw", error, resolve, reject);
1237
+ var result = record.arg;
1238
+ var value = result.value;
1239
+ if (value &&
1240
+ typeof value === "object" &&
1241
+ hasOwn.call(value, "__await")) {
1242
+ return PromiseImpl.resolve(value.__await).then(function(value) {
1243
+ invoke("next", value, resolve, reject);
1244
+ }, function(err) {
1245
+ invoke("throw", err, resolve, reject);
1256
1246
  });
1257
1247
  }
1248
+
1249
+ return PromiseImpl.resolve(value).then(function(unwrapped) {
1250
+ // When a yielded Promise is resolved, its final value becomes
1251
+ // the .value of the Promise<{value,done}> result for the
1252
+ // current iteration.
1253
+ result.value = unwrapped;
1254
+ resolve(result);
1255
+ }, function(error) {
1256
+ // If a rejected Promise was yielded, throw the rejection back
1257
+ // into the async generator function so it can be handled there.
1258
+ return invoke("throw", error, resolve, reject);
1259
+ });
1258
1260
  }
1261
+ }
1259
1262
 
1260
- var previousPromise;
1263
+ var previousPromise;
1261
1264
 
1262
- function enqueue(method, arg) {
1263
- function callInvokeWithMethodAndArg() {
1264
- return new PromiseImpl(function (resolve, reject) {
1265
- invoke(method, arg, resolve, reject);
1266
- });
1267
- }
1265
+ function enqueue(method, arg) {
1266
+ function callInvokeWithMethodAndArg() {
1267
+ return new PromiseImpl(function(resolve, reject) {
1268
+ invoke(method, arg, resolve, reject);
1269
+ });
1270
+ }
1268
1271
 
1269
- return previousPromise = // If enqueue has been called before, then we want to wait until
1272
+ return previousPromise =
1273
+ // If enqueue has been called before, then we want to wait until
1270
1274
  // all previous Promises have been resolved before calling invoke,
1271
1275
  // so that results are always delivered in the correct order. If
1272
1276
  // enqueue has not been called before, then it is important to
@@ -1278,527 +1282,554 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
1278
1282
  // execute code before the first await. Since we implement simple
1279
1283
  // async functions in terms of async generators, it is especially
1280
1284
  // important to get this right, even though it requires care.
1281
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
1282
- // invocations of the iterator.
1283
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
1284
- } // Define the unified helper method that is used to implement .next,
1285
- // .throw, and .return (see defineIteratorMethods).
1286
-
1287
-
1288
- this._invoke = enqueue;
1285
+ previousPromise ? previousPromise.then(
1286
+ callInvokeWithMethodAndArg,
1287
+ // Avoid propagating failures to Promises returned by later
1288
+ // invocations of the iterator.
1289
+ callInvokeWithMethodAndArg
1290
+ ) : callInvokeWithMethodAndArg();
1289
1291
  }
1290
1292
 
1291
- defineIteratorMethods(AsyncIterator.prototype);
1292
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
1293
- return this;
1294
- });
1295
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
1296
- // AsyncIterator objects; they just return a Promise for the value of
1297
- // the final result produced by the iterator.
1298
-
1299
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
1300
- if (PromiseImpl === void 0) PromiseImpl = Promise;
1301
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
1302
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
1303
- : iter.next().then(function (result) {
1304
- return result.done ? result.value : iter.next();
1305
- });
1306
- };
1293
+ // Define the unified helper method that is used to implement .next,
1294
+ // .throw, and .return (see defineIteratorMethods).
1295
+ this._invoke = enqueue;
1296
+ }
1307
1297
 
1308
- function makeInvokeMethod(innerFn, self, context) {
1309
- var state = GenStateSuspendedStart;
1310
- return function invoke(method, arg) {
1311
- if (state === GenStateExecuting) {
1312
- throw new Error("Generator is already running");
1313
- }
1298
+ defineIteratorMethods(AsyncIterator.prototype);
1299
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
1300
+ return this;
1301
+ });
1302
+ exports.AsyncIterator = AsyncIterator;
1303
+
1304
+ // Note that simple async functions are implemented on top of
1305
+ // AsyncIterator objects; they just return a Promise for the value of
1306
+ // the final result produced by the iterator.
1307
+ exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
1308
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
1309
+
1310
+ var iter = new AsyncIterator(
1311
+ wrap(innerFn, outerFn, self, tryLocsList),
1312
+ PromiseImpl
1313
+ );
1314
+
1315
+ return exports.isGeneratorFunction(outerFn)
1316
+ ? iter // If outerFn is a generator, return the full iterator.
1317
+ : iter.next().then(function(result) {
1318
+ return result.done ? result.value : iter.next();
1319
+ });
1320
+ };
1314
1321
 
1315
- if (state === GenStateCompleted) {
1316
- if (method === "throw") {
1317
- throw arg;
1318
- } // Be forgiving, per 25.3.3.3.3 of the spec:
1319
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
1322
+ function makeInvokeMethod(innerFn, self, context) {
1323
+ var state = GenStateSuspendedStart;
1320
1324
 
1325
+ return function invoke(method, arg) {
1326
+ if (state === GenStateExecuting) {
1327
+ throw new Error("Generator is already running");
1328
+ }
1321
1329
 
1322
- return doneResult();
1330
+ if (state === GenStateCompleted) {
1331
+ if (method === "throw") {
1332
+ throw arg;
1323
1333
  }
1324
1334
 
1325
- context.method = method;
1326
- context.arg = arg;
1327
-
1328
- while (true) {
1329
- var delegate = context.delegate;
1335
+ // Be forgiving, per 25.3.3.3.3 of the spec:
1336
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
1337
+ return doneResult();
1338
+ }
1330
1339
 
1331
- if (delegate) {
1332
- var delegateResult = maybeInvokeDelegate(delegate, context);
1340
+ context.method = method;
1341
+ context.arg = arg;
1333
1342
 
1334
- if (delegateResult) {
1335
- if (delegateResult === ContinueSentinel) continue;
1336
- return delegateResult;
1337
- }
1343
+ while (true) {
1344
+ var delegate = context.delegate;
1345
+ if (delegate) {
1346
+ var delegateResult = maybeInvokeDelegate(delegate, context);
1347
+ if (delegateResult) {
1348
+ if (delegateResult === ContinueSentinel) continue;
1349
+ return delegateResult;
1338
1350
  }
1351
+ }
1339
1352
 
1340
- if (context.method === "next") {
1341
- // Setting context._sent for legacy support of Babel's
1342
- // function.sent implementation.
1343
- context.sent = context._sent = context.arg;
1344
- } else if (context.method === "throw") {
1345
- if (state === GenStateSuspendedStart) {
1346
- state = GenStateCompleted;
1347
- throw context.arg;
1348
- }
1353
+ if (context.method === "next") {
1354
+ // Setting context._sent for legacy support of Babel's
1355
+ // function.sent implementation.
1356
+ context.sent = context._sent = context.arg;
1349
1357
 
1350
- context.dispatchException(context.arg);
1351
- } else if (context.method === "return") {
1352
- context.abrupt("return", context.arg);
1358
+ } else if (context.method === "throw") {
1359
+ if (state === GenStateSuspendedStart) {
1360
+ state = GenStateCompleted;
1361
+ throw context.arg;
1353
1362
  }
1354
1363
 
1355
- state = GenStateExecuting;
1356
- var record = tryCatch(innerFn, self, context);
1364
+ context.dispatchException(context.arg);
1357
1365
 
1358
- if (record.type === "normal") {
1359
- // If an exception is thrown from innerFn, we leave state ===
1360
- // GenStateExecuting and loop back for another invocation.
1361
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
1366
+ } else if (context.method === "return") {
1367
+ context.abrupt("return", context.arg);
1368
+ }
1362
1369
 
1363
- if (record.arg === ContinueSentinel) {
1364
- continue;
1365
- }
1370
+ state = GenStateExecuting;
1366
1371
 
1367
- return {
1368
- value: record.arg,
1369
- done: context.done
1370
- };
1371
- } else if (record.type === "throw") {
1372
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
1373
- // context.dispatchException(context.arg) call above.
1372
+ var record = tryCatch(innerFn, self, context);
1373
+ if (record.type === "normal") {
1374
+ // If an exception is thrown from innerFn, we leave state ===
1375
+ // GenStateExecuting and loop back for another invocation.
1376
+ state = context.done
1377
+ ? GenStateCompleted
1378
+ : GenStateSuspendedYield;
1374
1379
 
1375
- context.method = "throw";
1376
- context.arg = record.arg;
1377
- }
1378
- }
1379
- };
1380
- } // Call delegate.iterator[context.method](context.arg) and handle the
1381
- // result, either by returning a { value, done } result from the
1382
- // delegate iterator, or by modifying context.method and context.arg,
1383
- // setting context.delegate to null, and returning the ContinueSentinel.
1384
-
1385
-
1386
- function maybeInvokeDelegate(delegate, context) {
1387
- var method = delegate.iterator[context.method];
1388
-
1389
- if (method === undefined$1) {
1390
- // A .throw or .return when the delegate iterator has no .throw
1391
- // method always terminates the yield* loop.
1392
- context.delegate = null;
1393
-
1394
- if (context.method === "throw") {
1395
- // Note: ["return"] must be used for ES3 parsing compatibility.
1396
- if (delegate.iterator["return"]) {
1397
- // If the delegate iterator has a return method, give it a
1398
- // chance to clean up.
1399
- context.method = "return";
1400
- context.arg = undefined$1;
1401
- maybeInvokeDelegate(delegate, context);
1402
-
1403
- if (context.method === "throw") {
1404
- // If maybeInvokeDelegate(context) changed context.method from
1405
- // "return" to "throw", let that override the TypeError below.
1406
- return ContinueSentinel;
1407
- }
1380
+ if (record.arg === ContinueSentinel) {
1381
+ continue;
1408
1382
  }
1409
1383
 
1384
+ return {
1385
+ value: record.arg,
1386
+ done: context.done
1387
+ };
1388
+
1389
+ } else if (record.type === "throw") {
1390
+ state = GenStateCompleted;
1391
+ // Dispatch the exception by looping back around to the
1392
+ // context.dispatchException(context.arg) call above.
1410
1393
  context.method = "throw";
1411
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
1394
+ context.arg = record.arg;
1412
1395
  }
1413
-
1414
- return ContinueSentinel;
1415
1396
  }
1397
+ };
1398
+ }
1416
1399
 
1417
- var record = tryCatch(method, delegate.iterator, context.arg);
1400
+ // Call delegate.iterator[context.method](context.arg) and handle the
1401
+ // result, either by returning a { value, done } result from the
1402
+ // delegate iterator, or by modifying context.method and context.arg,
1403
+ // setting context.delegate to null, and returning the ContinueSentinel.
1404
+ function maybeInvokeDelegate(delegate, context) {
1405
+ var method = delegate.iterator[context.method];
1406
+ if (method === undefined$1) {
1407
+ // A .throw or .return when the delegate iterator has no .throw
1408
+ // method always terminates the yield* loop.
1409
+ context.delegate = null;
1418
1410
 
1419
- if (record.type === "throw") {
1420
- context.method = "throw";
1421
- context.arg = record.arg;
1422
- context.delegate = null;
1423
- return ContinueSentinel;
1424
- }
1411
+ if (context.method === "throw") {
1412
+ // Note: ["return"] must be used for ES3 parsing compatibility.
1413
+ if (delegate.iterator["return"]) {
1414
+ // If the delegate iterator has a return method, give it a
1415
+ // chance to clean up.
1416
+ context.method = "return";
1417
+ context.arg = undefined$1;
1418
+ maybeInvokeDelegate(delegate, context);
1425
1419
 
1426
- var info = record.arg;
1420
+ if (context.method === "throw") {
1421
+ // If maybeInvokeDelegate(context) changed context.method from
1422
+ // "return" to "throw", let that override the TypeError below.
1423
+ return ContinueSentinel;
1424
+ }
1425
+ }
1427
1426
 
1428
- if (!info) {
1429
1427
  context.method = "throw";
1430
- context.arg = new TypeError("iterator result is not an object");
1431
- context.delegate = null;
1432
- return ContinueSentinel;
1428
+ context.arg = new TypeError(
1429
+ "The iterator does not provide a 'throw' method");
1433
1430
  }
1434
1431
 
1435
- if (info.done) {
1436
- // Assign the result of the finished delegate to the temporary
1437
- // variable specified by delegate.resultName (see delegateYield).
1438
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
1439
-
1440
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
1441
- // exception, let the outer generator proceed normally. If
1442
- // context.method was "next", forget context.arg since it has been
1443
- // "consumed" by the delegate iterator. If context.method was
1444
- // "return", allow the original .return call to continue in the
1445
- // outer generator.
1446
-
1447
- if (context.method !== "return") {
1448
- context.method = "next";
1449
- context.arg = undefined$1;
1450
- }
1451
- } else {
1452
- // Re-yield the result returned by the delegate method.
1453
- return info;
1454
- } // The delegate iterator is finished, so forget it and continue with
1455
- // the outer generator.
1432
+ return ContinueSentinel;
1433
+ }
1456
1434
 
1435
+ var record = tryCatch(method, delegate.iterator, context.arg);
1457
1436
 
1437
+ if (record.type === "throw") {
1438
+ context.method = "throw";
1439
+ context.arg = record.arg;
1458
1440
  context.delegate = null;
1459
1441
  return ContinueSentinel;
1460
- } // Define Generator.prototype.{next,throw,return} in terms of the
1461
- // unified ._invoke helper method.
1462
-
1463
-
1464
- defineIteratorMethods(Gp);
1465
- define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
1466
- // @@iterator function is called on it. Some browsers' implementations of the
1467
- // iterator prototype chain incorrectly implement this, causing the Generator
1468
- // object to not be returned from this call. This ensures that doesn't happen.
1469
- // See https://github.com/facebook/regenerator/issues/274 for more details.
1470
-
1471
- define(Gp, iteratorSymbol, function () {
1472
- return this;
1473
- });
1474
- define(Gp, "toString", function () {
1475
- return "[object Generator]";
1476
- });
1442
+ }
1477
1443
 
1478
- function pushTryEntry(locs) {
1479
- var entry = {
1480
- tryLoc: locs[0]
1481
- };
1444
+ var info = record.arg;
1482
1445
 
1483
- if (1 in locs) {
1484
- entry.catchLoc = locs[1];
1485
- }
1446
+ if (! info) {
1447
+ context.method = "throw";
1448
+ context.arg = new TypeError("iterator result is not an object");
1449
+ context.delegate = null;
1450
+ return ContinueSentinel;
1451
+ }
1486
1452
 
1487
- if (2 in locs) {
1488
- entry.finallyLoc = locs[2];
1489
- entry.afterLoc = locs[3];
1453
+ if (info.done) {
1454
+ // Assign the result of the finished delegate to the temporary
1455
+ // variable specified by delegate.resultName (see delegateYield).
1456
+ context[delegate.resultName] = info.value;
1457
+
1458
+ // Resume execution at the desired location (see delegateYield).
1459
+ context.next = delegate.nextLoc;
1460
+
1461
+ // If context.method was "throw" but the delegate handled the
1462
+ // exception, let the outer generator proceed normally. If
1463
+ // context.method was "next", forget context.arg since it has been
1464
+ // "consumed" by the delegate iterator. If context.method was
1465
+ // "return", allow the original .return call to continue in the
1466
+ // outer generator.
1467
+ if (context.method !== "return") {
1468
+ context.method = "next";
1469
+ context.arg = undefined$1;
1490
1470
  }
1491
1471
 
1492
- this.tryEntries.push(entry);
1472
+ } else {
1473
+ // Re-yield the result returned by the delegate method.
1474
+ return info;
1493
1475
  }
1494
1476
 
1495
- function resetTryEntry(entry) {
1496
- var record = entry.completion || {};
1497
- record.type = "normal";
1498
- delete record.arg;
1499
- entry.completion = record;
1500
- }
1477
+ // The delegate iterator is finished, so forget it and continue with
1478
+ // the outer generator.
1479
+ context.delegate = null;
1480
+ return ContinueSentinel;
1481
+ }
1501
1482
 
1502
- function Context(tryLocsList) {
1503
- // The root entry object (effectively a try statement without a catch
1504
- // or a finally block) gives us a place to store values thrown from
1505
- // locations where there is no enclosing try statement.
1506
- this.tryEntries = [{
1507
- tryLoc: "root"
1508
- }];
1509
- tryLocsList.forEach(pushTryEntry, this);
1510
- this.reset(true);
1511
- }
1483
+ // Define Generator.prototype.{next,throw,return} in terms of the
1484
+ // unified ._invoke helper method.
1485
+ defineIteratorMethods(Gp);
1512
1486
 
1513
- exports.keys = function (object) {
1514
- var keys = [];
1487
+ define(Gp, toStringTagSymbol, "Generator");
1515
1488
 
1516
- for (var key in object) {
1517
- keys.push(key);
1518
- }
1489
+ // A Generator should always return itself as the iterator object when the
1490
+ // @@iterator function is called on it. Some browsers' implementations of the
1491
+ // iterator prototype chain incorrectly implement this, causing the Generator
1492
+ // object to not be returned from this call. This ensures that doesn't happen.
1493
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
1494
+ define(Gp, iteratorSymbol, function() {
1495
+ return this;
1496
+ });
1519
1497
 
1520
- keys.reverse(); // Rather than returning an object with a next method, we keep
1521
- // things simple and return the next function itself.
1498
+ define(Gp, "toString", function() {
1499
+ return "[object Generator]";
1500
+ });
1522
1501
 
1523
- return function next() {
1524
- while (keys.length) {
1525
- var key = keys.pop();
1502
+ function pushTryEntry(locs) {
1503
+ var entry = { tryLoc: locs[0] };
1526
1504
 
1527
- if (key in object) {
1528
- next.value = key;
1529
- next.done = false;
1530
- return next;
1531
- }
1532
- } // To avoid creating an additional object, we just hang the .value
1533
- // and .done properties off the next function object itself. This
1534
- // also ensures that the minifier will not anonymize the function.
1505
+ if (1 in locs) {
1506
+ entry.catchLoc = locs[1];
1507
+ }
1535
1508
 
1509
+ if (2 in locs) {
1510
+ entry.finallyLoc = locs[2];
1511
+ entry.afterLoc = locs[3];
1512
+ }
1536
1513
 
1537
- next.done = true;
1538
- return next;
1539
- };
1540
- };
1514
+ this.tryEntries.push(entry);
1515
+ }
1541
1516
 
1542
- function values(iterable) {
1543
- if (iterable) {
1544
- var iteratorMethod = iterable[iteratorSymbol];
1517
+ function resetTryEntry(entry) {
1518
+ var record = entry.completion || {};
1519
+ record.type = "normal";
1520
+ delete record.arg;
1521
+ entry.completion = record;
1522
+ }
1545
1523
 
1546
- if (iteratorMethod) {
1547
- return iteratorMethod.call(iterable);
1548
- }
1524
+ function Context(tryLocsList) {
1525
+ // The root entry object (effectively a try statement without a catch
1526
+ // or a finally block) gives us a place to store values thrown from
1527
+ // locations where there is no enclosing try statement.
1528
+ this.tryEntries = [{ tryLoc: "root" }];
1529
+ tryLocsList.forEach(pushTryEntry, this);
1530
+ this.reset(true);
1531
+ }
1549
1532
 
1550
- if (typeof iterable.next === "function") {
1551
- return iterable;
1533
+ exports.keys = function(object) {
1534
+ var keys = [];
1535
+ for (var key in object) {
1536
+ keys.push(key);
1537
+ }
1538
+ keys.reverse();
1539
+
1540
+ // Rather than returning an object with a next method, we keep
1541
+ // things simple and return the next function itself.
1542
+ return function next() {
1543
+ while (keys.length) {
1544
+ var key = keys.pop();
1545
+ if (key in object) {
1546
+ next.value = key;
1547
+ next.done = false;
1548
+ return next;
1552
1549
  }
1550
+ }
1553
1551
 
1554
- if (!isNaN(iterable.length)) {
1555
- var i = -1,
1556
- next = function next() {
1557
- while (++i < iterable.length) {
1558
- if (hasOwn.call(iterable, i)) {
1559
- next.value = iterable[i];
1560
- next.done = false;
1561
- return next;
1562
- }
1563
- }
1552
+ // To avoid creating an additional object, we just hang the .value
1553
+ // and .done properties off the next function object itself. This
1554
+ // also ensures that the minifier will not anonymize the function.
1555
+ next.done = true;
1556
+ return next;
1557
+ };
1558
+ };
1564
1559
 
1565
- next.value = undefined$1;
1566
- next.done = true;
1567
- return next;
1568
- };
1560
+ function values(iterable) {
1561
+ if (iterable) {
1562
+ var iteratorMethod = iterable[iteratorSymbol];
1563
+ if (iteratorMethod) {
1564
+ return iteratorMethod.call(iterable);
1565
+ }
1569
1566
 
1570
- return next.next = next;
1571
- }
1572
- } // Return an iterator with no values.
1567
+ if (typeof iterable.next === "function") {
1568
+ return iterable;
1569
+ }
1573
1570
 
1571
+ if (!isNaN(iterable.length)) {
1572
+ var i = -1, next = function next() {
1573
+ while (++i < iterable.length) {
1574
+ if (hasOwn.call(iterable, i)) {
1575
+ next.value = iterable[i];
1576
+ next.done = false;
1577
+ return next;
1578
+ }
1579
+ }
1574
1580
 
1575
- return {
1576
- next: doneResult
1577
- };
1578
- }
1581
+ next.value = undefined$1;
1582
+ next.done = true;
1579
1583
 
1580
- exports.values = values;
1584
+ return next;
1585
+ };
1581
1586
 
1582
- function doneResult() {
1583
- return {
1584
- value: undefined$1,
1585
- done: true
1586
- };
1587
+ return next.next = next;
1588
+ }
1587
1589
  }
1588
1590
 
1589
- Context.prototype = {
1590
- constructor: Context,
1591
- reset: function reset(skipTempReset) {
1592
- this.prev = 0;
1593
- this.next = 0; // Resetting context._sent for legacy support of Babel's
1594
- // function.sent implementation.
1591
+ // Return an iterator with no values.
1592
+ return { next: doneResult };
1593
+ }
1594
+ exports.values = values;
1595
1595
 
1596
- this.sent = this._sent = undefined$1;
1597
- this.done = false;
1598
- this.delegate = null;
1599
- this.method = "next";
1600
- this.arg = undefined$1;
1601
- this.tryEntries.forEach(resetTryEntry);
1596
+ function doneResult() {
1597
+ return { value: undefined$1, done: true };
1598
+ }
1602
1599
 
1603
- if (!skipTempReset) {
1604
- for (var name in this) {
1605
- // Not sure about the optimal order of these conditions:
1606
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
1607
- this[name] = undefined$1;
1608
- }
1600
+ Context.prototype = {
1601
+ constructor: Context,
1602
+
1603
+ reset: function(skipTempReset) {
1604
+ this.prev = 0;
1605
+ this.next = 0;
1606
+ // Resetting context._sent for legacy support of Babel's
1607
+ // function.sent implementation.
1608
+ this.sent = this._sent = undefined$1;
1609
+ this.done = false;
1610
+ this.delegate = null;
1611
+
1612
+ this.method = "next";
1613
+ this.arg = undefined$1;
1614
+
1615
+ this.tryEntries.forEach(resetTryEntry);
1616
+
1617
+ if (!skipTempReset) {
1618
+ for (var name in this) {
1619
+ // Not sure about the optimal order of these conditions:
1620
+ if (name.charAt(0) === "t" &&
1621
+ hasOwn.call(this, name) &&
1622
+ !isNaN(+name.slice(1))) {
1623
+ this[name] = undefined$1;
1609
1624
  }
1610
1625
  }
1611
- },
1612
- stop: function stop() {
1613
- this.done = true;
1614
- var rootEntry = this.tryEntries[0];
1615
- var rootRecord = rootEntry.completion;
1626
+ }
1627
+ },
1616
1628
 
1617
- if (rootRecord.type === "throw") {
1618
- throw rootRecord.arg;
1619
- }
1629
+ stop: function() {
1630
+ this.done = true;
1620
1631
 
1621
- return this.rval;
1622
- },
1623
- dispatchException: function dispatchException(exception) {
1624
- if (this.done) {
1625
- throw exception;
1626
- }
1632
+ var rootEntry = this.tryEntries[0];
1633
+ var rootRecord = rootEntry.completion;
1634
+ if (rootRecord.type === "throw") {
1635
+ throw rootRecord.arg;
1636
+ }
1627
1637
 
1628
- var context = this;
1638
+ return this.rval;
1639
+ },
1629
1640
 
1630
- function handle(loc, caught) {
1631
- record.type = "throw";
1632
- record.arg = exception;
1633
- context.next = loc;
1641
+ dispatchException: function(exception) {
1642
+ if (this.done) {
1643
+ throw exception;
1644
+ }
1634
1645
 
1635
- if (caught) {
1636
- // If the dispatched exception was caught by a catch block,
1637
- // then let that catch block handle the exception normally.
1638
- context.method = "next";
1639
- context.arg = undefined$1;
1640
- }
1646
+ var context = this;
1647
+ function handle(loc, caught) {
1648
+ record.type = "throw";
1649
+ record.arg = exception;
1650
+ context.next = loc;
1641
1651
 
1642
- return !!caught;
1652
+ if (caught) {
1653
+ // If the dispatched exception was caught by a catch block,
1654
+ // then let that catch block handle the exception normally.
1655
+ context.method = "next";
1656
+ context.arg = undefined$1;
1643
1657
  }
1644
1658
 
1645
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1646
- var entry = this.tryEntries[i];
1647
- var record = entry.completion;
1659
+ return !! caught;
1660
+ }
1648
1661
 
1649
- if (entry.tryLoc === "root") {
1650
- // Exception thrown outside of any try block that could handle
1651
- // it, so set the completion value of the entire function to
1652
- // throw the exception.
1653
- return handle("end");
1654
- }
1662
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1663
+ var entry = this.tryEntries[i];
1664
+ var record = entry.completion;
1665
+
1666
+ if (entry.tryLoc === "root") {
1667
+ // Exception thrown outside of any try block that could handle
1668
+ // it, so set the completion value of the entire function to
1669
+ // throw the exception.
1670
+ return handle("end");
1671
+ }
1655
1672
 
1656
- if (entry.tryLoc <= this.prev) {
1657
- var hasCatch = hasOwn.call(entry, "catchLoc");
1658
- var hasFinally = hasOwn.call(entry, "finallyLoc");
1673
+ if (entry.tryLoc <= this.prev) {
1674
+ var hasCatch = hasOwn.call(entry, "catchLoc");
1675
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
1659
1676
 
1660
- if (hasCatch && hasFinally) {
1661
- if (this.prev < entry.catchLoc) {
1662
- return handle(entry.catchLoc, true);
1663
- } else if (this.prev < entry.finallyLoc) {
1664
- return handle(entry.finallyLoc);
1665
- }
1666
- } else if (hasCatch) {
1667
- if (this.prev < entry.catchLoc) {
1668
- return handle(entry.catchLoc, true);
1669
- }
1670
- } else if (hasFinally) {
1671
- if (this.prev < entry.finallyLoc) {
1672
- return handle(entry.finallyLoc);
1673
- }
1674
- } else {
1675
- throw new Error("try statement without catch or finally");
1677
+ if (hasCatch && hasFinally) {
1678
+ if (this.prev < entry.catchLoc) {
1679
+ return handle(entry.catchLoc, true);
1680
+ } else if (this.prev < entry.finallyLoc) {
1681
+ return handle(entry.finallyLoc);
1682
+ }
1683
+
1684
+ } else if (hasCatch) {
1685
+ if (this.prev < entry.catchLoc) {
1686
+ return handle(entry.catchLoc, true);
1687
+ }
1688
+
1689
+ } else if (hasFinally) {
1690
+ if (this.prev < entry.finallyLoc) {
1691
+ return handle(entry.finallyLoc);
1676
1692
  }
1677
- }
1678
- }
1679
- },
1680
- abrupt: function abrupt(type, arg) {
1681
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1682
- var entry = this.tryEntries[i];
1683
1693
 
1684
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
1685
- var finallyEntry = entry;
1686
- break;
1694
+ } else {
1695
+ throw new Error("try statement without catch or finally");
1687
1696
  }
1688
1697
  }
1698
+ }
1699
+ },
1689
1700
 
1690
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
1691
- // Ignore the finally entry if control is not jumping to a
1692
- // location outside the try/catch block.
1693
- finallyEntry = null;
1701
+ abrupt: function(type, arg) {
1702
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1703
+ var entry = this.tryEntries[i];
1704
+ if (entry.tryLoc <= this.prev &&
1705
+ hasOwn.call(entry, "finallyLoc") &&
1706
+ this.prev < entry.finallyLoc) {
1707
+ var finallyEntry = entry;
1708
+ break;
1694
1709
  }
1710
+ }
1695
1711
 
1696
- var record = finallyEntry ? finallyEntry.completion : {};
1697
- record.type = type;
1698
- record.arg = arg;
1712
+ if (finallyEntry &&
1713
+ (type === "break" ||
1714
+ type === "continue") &&
1715
+ finallyEntry.tryLoc <= arg &&
1716
+ arg <= finallyEntry.finallyLoc) {
1717
+ // Ignore the finally entry if control is not jumping to a
1718
+ // location outside the try/catch block.
1719
+ finallyEntry = null;
1720
+ }
1699
1721
 
1700
- if (finallyEntry) {
1701
- this.method = "next";
1702
- this.next = finallyEntry.finallyLoc;
1703
- return ContinueSentinel;
1704
- }
1722
+ var record = finallyEntry ? finallyEntry.completion : {};
1723
+ record.type = type;
1724
+ record.arg = arg;
1705
1725
 
1706
- return this.complete(record);
1707
- },
1708
- complete: function complete(record, afterLoc) {
1709
- if (record.type === "throw") {
1710
- throw record.arg;
1711
- }
1726
+ if (finallyEntry) {
1727
+ this.method = "next";
1728
+ this.next = finallyEntry.finallyLoc;
1729
+ return ContinueSentinel;
1730
+ }
1712
1731
 
1713
- if (record.type === "break" || record.type === "continue") {
1714
- this.next = record.arg;
1715
- } else if (record.type === "return") {
1716
- this.rval = this.arg = record.arg;
1717
- this.method = "return";
1718
- this.next = "end";
1719
- } else if (record.type === "normal" && afterLoc) {
1720
- this.next = afterLoc;
1721
- }
1732
+ return this.complete(record);
1733
+ },
1722
1734
 
1723
- return ContinueSentinel;
1724
- },
1725
- finish: function finish(finallyLoc) {
1726
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1727
- var entry = this.tryEntries[i];
1735
+ complete: function(record, afterLoc) {
1736
+ if (record.type === "throw") {
1737
+ throw record.arg;
1738
+ }
1728
1739
 
1729
- if (entry.finallyLoc === finallyLoc) {
1730
- this.complete(entry.completion, entry.afterLoc);
1731
- resetTryEntry(entry);
1732
- return ContinueSentinel;
1733
- }
1734
- }
1735
- },
1736
- "catch": function _catch(tryLoc) {
1737
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1738
- var entry = this.tryEntries[i];
1740
+ if (record.type === "break" ||
1741
+ record.type === "continue") {
1742
+ this.next = record.arg;
1743
+ } else if (record.type === "return") {
1744
+ this.rval = this.arg = record.arg;
1745
+ this.method = "return";
1746
+ this.next = "end";
1747
+ } else if (record.type === "normal" && afterLoc) {
1748
+ this.next = afterLoc;
1749
+ }
1739
1750
 
1740
- if (entry.tryLoc === tryLoc) {
1741
- var record = entry.completion;
1751
+ return ContinueSentinel;
1752
+ },
1742
1753
 
1743
- if (record.type === "throw") {
1744
- var thrown = record.arg;
1745
- resetTryEntry(entry);
1746
- }
1754
+ finish: function(finallyLoc) {
1755
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1756
+ var entry = this.tryEntries[i];
1757
+ if (entry.finallyLoc === finallyLoc) {
1758
+ this.complete(entry.completion, entry.afterLoc);
1759
+ resetTryEntry(entry);
1760
+ return ContinueSentinel;
1761
+ }
1762
+ }
1763
+ },
1747
1764
 
1748
- return thrown;
1765
+ "catch": function(tryLoc) {
1766
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1767
+ var entry = this.tryEntries[i];
1768
+ if (entry.tryLoc === tryLoc) {
1769
+ var record = entry.completion;
1770
+ if (record.type === "throw") {
1771
+ var thrown = record.arg;
1772
+ resetTryEntry(entry);
1749
1773
  }
1750
- } // The context.catch method must only be called with a location
1751
- // argument that corresponds to a known catch block.
1752
-
1774
+ return thrown;
1775
+ }
1776
+ }
1753
1777
 
1754
- throw new Error("illegal catch attempt");
1755
- },
1756
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
1757
- this.delegate = {
1758
- iterator: values(iterable),
1759
- resultName: resultName,
1760
- nextLoc: nextLoc
1761
- };
1778
+ // The context.catch method must only be called with a location
1779
+ // argument that corresponds to a known catch block.
1780
+ throw new Error("illegal catch attempt");
1781
+ },
1762
1782
 
1763
- if (this.method === "next") {
1764
- // Deliberately forget the last sent value so that we don't
1765
- // accidentally pass it on to the delegate.
1766
- this.arg = undefined$1;
1767
- }
1783
+ delegateYield: function(iterable, resultName, nextLoc) {
1784
+ this.delegate = {
1785
+ iterator: values(iterable),
1786
+ resultName: resultName,
1787
+ nextLoc: nextLoc
1788
+ };
1768
1789
 
1769
- return ContinueSentinel;
1790
+ if (this.method === "next") {
1791
+ // Deliberately forget the last sent value so that we don't
1792
+ // accidentally pass it on to the delegate.
1793
+ this.arg = undefined$1;
1770
1794
  }
1771
- }; // Regardless of whether this script is executing as a CommonJS module
1772
- // or not, return the runtime object so that we can declare the variable
1773
- // regeneratorRuntime in the outer scope, which allows this module to be
1774
- // injected easily by `bin/regenerator --include-runtime script.js`.
1775
1795
 
1776
- return exports;
1777
- }( // If this script is executing as a CommonJS module, use module.exports
1796
+ return ContinueSentinel;
1797
+ }
1798
+ };
1799
+
1800
+ // Regardless of whether this script is executing as a CommonJS module
1801
+ // or not, return the runtime object so that we can declare the variable
1802
+ // regeneratorRuntime in the outer scope, which allows this module to be
1803
+ // injected easily by `bin/regenerator --include-runtime script.js`.
1804
+ return exports;
1805
+
1806
+ }(
1807
+ // If this script is executing as a CommonJS module, use module.exports
1778
1808
  // as the regeneratorRuntime namespace. Otherwise create a new empty
1779
1809
  // object. Either way, the resulting object will be used to initialize
1780
1810
  // the regeneratorRuntime variable at the top of this file.
1781
- module.exports );
1782
-
1783
- try {
1784
- regeneratorRuntime = runtime;
1785
- } catch (accidentalStrictMode) {
1786
- // This module should not be running in strict mode, so the above
1787
- // assignment should always work unless something is misconfigured. Just
1788
- // in case runtime.js accidentally runs in strict mode, in modern engines
1789
- // we can explicitly access globalThis. In older engines we can escape
1790
- // strict mode using a global Function call. This could conceivably fail
1791
- // if a Content Security Policy forbids using Function, but in that case
1792
- // the proper solution is to fix the accidental strict mode problem. If
1793
- // you've misconfigured your bundler to force strict mode and applied a
1794
- // CSP to forbid Function, and you're not willing to fix either of those
1795
- // problems, please detail your unique predicament in a GitHub issue.
1796
- if (typeof globalThis === "object") {
1797
- globalThis.regeneratorRuntime = runtime;
1798
- } else {
1799
- Function("r", "regeneratorRuntime = r")(runtime);
1800
- }
1811
+ module.exports
1812
+ ));
1813
+
1814
+ try {
1815
+ regeneratorRuntime = runtime;
1816
+ } catch (accidentalStrictMode) {
1817
+ // This module should not be running in strict mode, so the above
1818
+ // assignment should always work unless something is misconfigured. Just
1819
+ // in case runtime.js accidentally runs in strict mode, in modern engines
1820
+ // we can explicitly access globalThis. In older engines we can escape
1821
+ // strict mode using a global Function call. This could conceivably fail
1822
+ // if a Content Security Policy forbids using Function, but in that case
1823
+ // the proper solution is to fix the accidental strict mode problem. If
1824
+ // you've misconfigured your bundler to force strict mode and applied a
1825
+ // CSP to forbid Function, and you're not willing to fix either of those
1826
+ // problems, please detail your unique predicament in a GitHub issue.
1827
+ if (typeof globalThis === "object") {
1828
+ globalThis.regeneratorRuntime = runtime;
1829
+ } else {
1830
+ Function("r", "regeneratorRuntime = r")(runtime);
1801
1831
  }
1832
+ }
1802
1833
  });
1803
1834
 
1804
1835
  /* eslint-disable you-dont-need-lodash-underscore/find */
@@ -2506,15 +2537,10 @@ function ToolbarHeadingButton(props) {
2506
2537
  if (!(editor != null && editor.selection)) return;
2507
2538
  setSelected(type);
2508
2539
  setOpen(false);
2509
-
2510
- if (shouldUnwrapBlockquote(editor, type)) {
2511
- unwrapFromRoot(editor);
2512
- }
2513
-
2514
2540
  var prevOnChange = editor.onChange;
2515
2541
  /*
2516
2542
  The focus might happen at point in time when
2517
- `toggleNodeType` changes aren't rendered yet, causing the browser
2543
+ `toggleElement` (helper for toggleNodeType) changes aren't rendered yet, causing the browser
2518
2544
  to place the cursor at the start of the text.
2519
2545
  We wait for the change event before focusing
2520
2546
  the editor again. This ensures the cursor is back at the previous
@@ -2530,7 +2556,7 @@ function ToolbarHeadingButton(props) {
2530
2556
  editor.tracking.onToolbarAction(isActive ? 'remove' : 'insert', {
2531
2557
  nodeType: type
2532
2558
  });
2533
- plateCore.toggleNodeType(editor, {
2559
+ toggleElement(editor, {
2534
2560
  activeType: type,
2535
2561
  inactiveType: type
2536
2562
  });
@@ -2660,7 +2686,7 @@ var buildHeadingEventHandler = function buildHeadingEventHandler(type) {
2660
2686
  editor.tracking.onShortcutAction(isActive ? 'remove' : 'insert', {
2661
2687
  nodeType: type
2662
2688
  });
2663
- plateCore.toggleNodeType(editor, {
2689
+ toggleElement(editor, {
2664
2690
  activeType: type,
2665
2691
  inactiveType: Contentful.BLOCKS.PARAGRAPH
2666
2692
  });
@@ -3726,6 +3752,16 @@ var replaceNodeWithListItems = function replaceNodeWithListItems(editor, entry)
3726
3752
  at: path
3727
3753
  });
3728
3754
  };
3755
+ var isListTypeActive = function isListTypeActive(editor, type) {
3756
+ // Lists can be nested. Here, we take the list type at the lowest level
3757
+ var listNode = plateCore.getBlockAbove(editor, {
3758
+ match: {
3759
+ type: [Contentful.BLOCKS.OL_LIST, Contentful.BLOCKS.UL_LIST]
3760
+ },
3761
+ mode: 'lowest'
3762
+ });
3763
+ return (listNode == null ? void 0 : listNode[0].type) === type;
3764
+ };
3729
3765
 
3730
3766
  /**
3731
3767
  * Build a new list item node while preserving marks
@@ -4095,6 +4131,178 @@ var createListPlugin = function createListPlugin() {
4095
4131
  });
4096
4132
  };
4097
4133
 
4134
+ var listTypes = [Contentful.BLOCKS.UL_LIST, Contentful.BLOCKS.OL_LIST];
4135
+
4136
+ var unwrapList = function unwrapList(editor, _temp) {
4137
+ var _ref = _temp === void 0 ? {} : _temp,
4138
+ at = _ref.at;
4139
+
4140
+ slate.Editor.withoutNormalizing(editor, function () {
4141
+ do {
4142
+ plateCore.unwrapNodes(editor, {
4143
+ at: at,
4144
+ match: {
4145
+ type: Contentful.BLOCKS.LIST_ITEM
4146
+ },
4147
+ split: true
4148
+ });
4149
+ plateCore.unwrapNodes(editor, {
4150
+ at: at,
4151
+ match: {
4152
+ type: listTypes
4153
+ },
4154
+ split: true
4155
+ });
4156
+ } while (plateCore.getAbove(editor, {
4157
+ match: {
4158
+ type: listTypes,
4159
+ at: at
4160
+ }
4161
+ }));
4162
+ });
4163
+ };
4164
+
4165
+ var toggleList = function toggleList(editor, _ref2) {
4166
+ var type = _ref2.type;
4167
+ return slate.Editor.withoutNormalizing(editor, function () {
4168
+ if (!editor.selection) {
4169
+ return;
4170
+ }
4171
+
4172
+ if (plateCore.isCollapsed(editor.selection) || !plateCore.isRangeAcrossBlocks(editor)) {
4173
+ // selection is collapsed
4174
+ var res = plateList.getListItemEntry(editor);
4175
+
4176
+ if (res) {
4177
+ var list = res.list;
4178
+
4179
+ if (list[0].type !== type) {
4180
+ plateCore.setNodes(editor, {
4181
+ type: type
4182
+ }, {
4183
+ at: editor.selection,
4184
+ match: function match(n) {
4185
+ return listTypes.includes(n.type);
4186
+ },
4187
+ mode: 'lowest'
4188
+ });
4189
+ } else {
4190
+ unwrapList(editor);
4191
+ }
4192
+ } else {
4193
+ var _list = {
4194
+ type: type,
4195
+ children: [],
4196
+ data: {}
4197
+ };
4198
+ plateCore.wrapNodes(editor, _list);
4199
+ var nodes = [].concat(plateCore.getNodes(editor, {
4200
+ match: {
4201
+ type: plateCore.getPluginType(editor, plateCore.ELEMENT_DEFAULT)
4202
+ }
4203
+ }));
4204
+ var listItem = {
4205
+ type: Contentful.BLOCKS.LIST_ITEM,
4206
+ children: [],
4207
+ data: {}
4208
+ };
4209
+
4210
+ for (var _iterator = _createForOfIteratorHelperLoose(nodes), _step; !(_step = _iterator()).done;) {
4211
+ var _step$value = _step.value,
4212
+ path = _step$value[1];
4213
+ plateCore.wrapNodes(editor, listItem, {
4214
+ at: path
4215
+ });
4216
+ }
4217
+ }
4218
+ } else {
4219
+ // selection is a range
4220
+ var _Range$edges = slate.Range.edges(editor.selection),
4221
+ startPoint = _Range$edges[0],
4222
+ endPoint = _Range$edges[1];
4223
+
4224
+ var commonEntry = slate.Node.common(editor, startPoint.path, endPoint.path);
4225
+
4226
+ if (listTypes.includes(commonEntry[0].type) || commonEntry[0].type === Contentful.BLOCKS.LIST_ITEM) {
4227
+ if (commonEntry[0].type !== type) {
4228
+ var startList = plateCore.findNode(editor, {
4229
+ at: slate.Range.start(editor.selection),
4230
+ match: {
4231
+ type: listTypes
4232
+ },
4233
+ mode: 'lowest'
4234
+ });
4235
+ var endList = plateCore.findNode(editor, {
4236
+ at: slate.Range.end(editor.selection),
4237
+ match: {
4238
+ type: listTypes
4239
+ },
4240
+ mode: 'lowest'
4241
+ });
4242
+
4243
+ if (!startList || !endList) {
4244
+ return;
4245
+ }
4246
+
4247
+ var rangeLength = Math.min(startList[1].length, endList[1].length);
4248
+ plateCore.setNodes(editor, {
4249
+ type: type
4250
+ }, {
4251
+ at: editor.selection,
4252
+ match: function match(n, path) {
4253
+ return listTypes.includes(n.type) && path.length >= rangeLength;
4254
+ },
4255
+ mode: 'all'
4256
+ });
4257
+ } else {
4258
+ unwrapList(editor);
4259
+ }
4260
+ } else {
4261
+ var rootPathLength = commonEntry[1].length;
4262
+
4263
+ var _nodes = Array.from(plateCore.getNodes(editor, {
4264
+ mode: 'all'
4265
+ })).filter(function (_ref3) {
4266
+ var path = _ref3[1];
4267
+ return path.length === rootPathLength + 1;
4268
+ }).reverse();
4269
+
4270
+ _nodes.forEach(function (n) {
4271
+ if (listTypes.includes(n[0].type)) {
4272
+ plateCore.setNodes(editor, {
4273
+ type: type
4274
+ }, {
4275
+ at: n[1]
4276
+ });
4277
+ } else {
4278
+ plateCore.setNodes(editor, {
4279
+ type: plateCore.getPluginType(editor, plateList.ELEMENT_LIC)
4280
+ }, {
4281
+ at: n[1]
4282
+ });
4283
+ var _listItem = {
4284
+ type: Contentful.BLOCKS.LIST_ITEM,
4285
+ children: [],
4286
+ data: {}
4287
+ };
4288
+ plateCore.wrapNodes(editor, _listItem, {
4289
+ at: n[1]
4290
+ });
4291
+ var _list2 = {
4292
+ type: type,
4293
+ children: [],
4294
+ data: {}
4295
+ };
4296
+ plateCore.wrapNodes(editor, _list2, {
4297
+ at: n[1]
4298
+ });
4299
+ }
4300
+ });
4301
+ }
4302
+ }
4303
+ });
4304
+ };
4305
+
4098
4306
  function ToolbarListButton(props) {
4099
4307
  var sdk = useSdkContext();
4100
4308
  var editor = useContentfulEditor();
@@ -4102,12 +4310,7 @@ function ToolbarListButton(props) {
4102
4310
  function handleClick(type) {
4103
4311
  return function () {
4104
4312
  if (!(editor != null && editor.selection)) return;
4105
-
4106
- if (shouldUnwrapBlockquote(editor, type)) {
4107
- unwrapFromRoot(editor);
4108
- }
4109
-
4110
- plateList.toggleList(editor, {
4313
+ toggleList(editor, {
4111
4314
  type: type
4112
4315
  });
4113
4316
  focus(editor);
@@ -4119,13 +4322,13 @@ function ToolbarListButton(props) {
4119
4322
  title: "UL",
4120
4323
  testId: "ul-toolbar-button",
4121
4324
  onClick: handleClick(Contentful.BLOCKS.UL_LIST),
4122
- isActive: isBlockSelected(editor, Contentful.BLOCKS.UL_LIST),
4325
+ isActive: isListTypeActive(editor, Contentful.BLOCKS.UL_LIST),
4123
4326
  isDisabled: props.isDisabled
4124
4327
  }, /*#__PURE__*/React.createElement(f36Icons.ListBulletedIcon, null)), isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.OL_LIST) && /*#__PURE__*/React.createElement(ToolbarButton, {
4125
4328
  title: "OL",
4126
4329
  testId: "ol-toolbar-button",
4127
4330
  onClick: handleClick(Contentful.BLOCKS.OL_LIST),
4128
- isActive: isBlockSelected(editor, Contentful.BLOCKS.OL_LIST),
4331
+ isActive: isListTypeActive(editor, Contentful.BLOCKS.OL_LIST),
4129
4332
  isDisabled: props.isDisabled
4130
4333
  }, /*#__PURE__*/React.createElement(f36Icons.ListNumberedIcon, null)));
4131
4334
  }
@@ -4568,6 +4771,18 @@ function isEmptyElement(element) {
4568
4771
  return element.textContent === '';
4569
4772
  }
4570
4773
 
4774
+ var buildParagraphKeyDownHandler = function buildParagraphKeyDownHandler(editor, _ref) {
4775
+ var hotkey = _ref.options.hotkey;
4776
+ return function (event) {
4777
+ if (editor.selection && hotkey && isHotkey(hotkey, event)) {
4778
+ toggleElement(editor, {
4779
+ activeType: Contentful.BLOCKS.PARAGRAPH,
4780
+ inactiveType: Contentful.BLOCKS.PARAGRAPH
4781
+ });
4782
+ }
4783
+ };
4784
+ };
4785
+
4571
4786
  var createParagraphPlugin = function createParagraphPlugin() {
4572
4787
  var _transform;
4573
4788
 
@@ -4577,6 +4792,9 @@ var createParagraphPlugin = function createParagraphPlugin() {
4577
4792
  options: {
4578
4793
  hotkey: ['mod+opt+0']
4579
4794
  },
4795
+ handlers: {
4796
+ onKeyDown: buildParagraphKeyDownHandler
4797
+ },
4580
4798
  softBreak: [// create a new line with SHIFT+Enter inside a paragraph
4581
4799
  {
4582
4800
  hotkey: 'shift+enter',
@@ -4593,8 +4811,8 @@ var createParagraphPlugin = function createParagraphPlugin() {
4593
4811
  }
4594
4812
  },
4595
4813
  normalizer: [{
4596
- validChildren: function validChildren(_, _ref) {
4597
- var node = _ref[0];
4814
+ validChildren: function validChildren(_, _ref2) {
4815
+ var node = _ref2[0];
4598
4816
  return isInlineOrText(node);
4599
4817
  },
4600
4818
  transform: (_transform = {}, _transform[Contentful.BLOCKS.PARAGRAPH] = transformUnwrap, _transform["default"] = transformLift, _transform)
@@ -4758,10 +4976,7 @@ var style$1 = /*#__PURE__*/emotion.css({
4758
4976
  margin: '0 0 1.3125rem',
4759
4977
  borderLeft: "6px solid " + tokens.gray200,
4760
4978
  paddingLeft: '0.875rem',
4761
- fontStyle: 'normal',
4762
- '& a': {
4763
- color: 'inherit'
4764
- }
4979
+ fontStyle: 'normal'
4765
4980
  });
4766
4981
  function Quote(props) {
4767
4982
  return /*#__PURE__*/React.createElement("blockquote", Object.assign({}, props.attributes, {
@@ -4832,7 +5047,7 @@ function createQuotePlugin() {
4832
5047
  },
4833
5048
  normalizer: [{
4834
5049
  validChildren: Contentful.CONTAINERS[Contentful.BLOCKS.QUOTE],
4835
- transform: (_transform = {}, _transform[Contentful.BLOCKS.QUOTE] = transformUnwrap, _transform[Contentful.BLOCKS.HEADING_1] = transformUnwrap, _transform[Contentful.BLOCKS.HEADING_2] = transformUnwrap, _transform[Contentful.BLOCKS.HEADING_3] = transformUnwrap, _transform[Contentful.BLOCKS.HEADING_4] = transformUnwrap, _transform[Contentful.BLOCKS.HEADING_5] = transformUnwrap, _transform[Contentful.BLOCKS.HEADING_6] = transformUnwrap, _transform["default"] = transformLift, _transform)
5050
+ transform: (_transform = {}, _transform[Contentful.BLOCKS.QUOTE] = transformUnwrap, _transform["default"] = transformLift, _transform)
4836
5051
  }],
4837
5052
  withOverrides: function withOverrides(editor) {
4838
5053
  var insertFragment = editor.insertFragment;
@@ -6164,8 +6379,9 @@ var useOnValueChanged = function useOnValueChanged(_ref) {
6164
6379
 
6165
6380
  var _excluded = ["sdk", "isInitiallyDisabled", "onAction"];
6166
6381
  var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
6167
- var id = useContentfulEditorId();
6168
- var editor = useContentfulEditor();
6382
+ var id = getContentfulEditorId(props.sdk); // TODO: remove in favor of getting the editor from useNormalizedSlateValue after upgrading to Plate v10
6383
+
6384
+ var editor = useContentfulEditor(id);
6169
6385
  var plugins = React__default.useMemo(function () {
6170
6386
  var _props$onAction;
6171
6387
 
@@ -6183,7 +6399,20 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
6183
6399
  var classNames = emotion.cx(styles$j.editor, props.minHeight !== undefined ? emotion.css({
6184
6400
  minHeight: props.minHeight
6185
6401
  }) : undefined, props.isDisabled ? styles$j.disabled : styles$j.enabled, props.isToolbarHidden && styles$j.hiddenToolbar);
6186
- return /*#__PURE__*/React__default.createElement("div", {
6402
+ React.useEffect(function () {
6403
+ // Ensure the plate state is cleared after the component unmounts
6404
+ // This prevent new editors for the same field to display old outdated values
6405
+ // Typical scenario: coming back to the entry editor after restoring a previous entry version
6406
+ plateCore.getPlateActions(id).enabled(true);
6407
+ return function () {
6408
+ return plateCore.getPlateActions(id).enabled(false);
6409
+ };
6410
+ }, [id]);
6411
+ return /*#__PURE__*/React__default.createElement(SdkProvider, {
6412
+ sdk: props.sdk
6413
+ }, /*#__PURE__*/React__default.createElement(ContentfulEditorIdProvider, {
6414
+ value: id
6415
+ }, /*#__PURE__*/React__default.createElement("div", {
6187
6416
  className: styles$j.root,
6188
6417
  "data-test-id": "rich-text-editor"
6189
6418
  }, /*#__PURE__*/React__default.createElement(plateCore.Plate, {
@@ -6200,7 +6429,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
6200
6429
  isDisabled: props.isDisabled
6201
6430
  }, /*#__PURE__*/React__default.createElement(Toolbar, {
6202
6431
  isDisabled: props.isDisabled
6203
- }))));
6432
+ }))))));
6204
6433
  };
6205
6434
 
6206
6435
  var RichTextEditor = function RichTextEditor(props) {
@@ -6212,11 +6441,8 @@ var RichTextEditor = function RichTextEditor(props) {
6212
6441
  var isEmptyValue = React.useCallback(function (value) {
6213
6442
  return !value || deepEquals(value, Contentful.EMPTY_DOCUMENT);
6214
6443
  }, []);
6215
- var editorId = getContentfulEditorId(sdk);
6216
6444
  return /*#__PURE__*/React__default.createElement(fieldEditorReference.EntityProvider, {
6217
6445
  sdk: sdk
6218
- }, /*#__PURE__*/React__default.createElement(SdkProvider, {
6219
- sdk: sdk
6220
6446
  }, /*#__PURE__*/React__default.createElement(fieldEditorShared.FieldConnector, {
6221
6447
  throttle: 0,
6222
6448
  field: sdk.field,
@@ -6228,17 +6454,15 @@ var RichTextEditor = function RichTextEditor(props) {
6228
6454
  disabled = _ref.disabled,
6229
6455
  setValue = _ref.setValue,
6230
6456
  externalReset = _ref.externalReset;
6231
- return /*#__PURE__*/React__default.createElement(ContentfulEditorIdProvider, {
6232
- value: editorId
6233
- }, /*#__PURE__*/React__default.createElement(ConnectedRichTextEditor, Object.assign({}, otherProps, {
6457
+ return /*#__PURE__*/React__default.createElement(ConnectedRichTextEditor, Object.assign({}, otherProps, {
6234
6458
  key: "rich-text-editor-" + externalReset,
6235
6459
  value: lastRemoteValue,
6236
6460
  sdk: sdk,
6237
6461
  onAction: onAction,
6238
6462
  isDisabled: disabled,
6239
6463
  onChange: setValue
6240
- })));
6241
- })));
6464
+ }));
6465
+ }));
6242
6466
  };
6243
6467
 
6244
6468
  var LINK_TYPES$1 = {