@contentful/field-editor-rich-text 3.4.8 → 3.4.9

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.
@@ -2772,21 +2772,24 @@ function watchCurrentSlide(navigator) {
2772
2772
  };
2773
2773
  };
2774
2774
 
2775
- var off = navigator.onSlideInNavigation(function (info) {
2775
+ var off = navigator.onSlideInNavigation(function (_ref) {
2776
+ var oldSlideLevel = _ref.oldSlideLevel,
2777
+ newSlideLevel = _ref.newSlideLevel;
2778
+
2776
2779
  if (initialSlideLevel === undefined) {
2777
- initialSlideLevel = info.oldSlideLevel;
2780
+ initialSlideLevel = oldSlideLevel;
2778
2781
  }
2779
2782
 
2780
- lastSlideLevel = info.newSlideLevel;
2783
+ lastSlideLevel = newSlideLevel;
2781
2784
 
2782
- if (info.newSlideLevel < initialSlideLevel) {
2785
+ if (newSlideLevel < initialSlideLevel) {
2783
2786
  wasSlideClosed = true;
2784
2787
  off(); // No more point in watching, slide got closed.
2785
2788
 
2786
2789
  onActiveCallbacks.clear();
2787
2790
  }
2788
2791
 
2789
- if (status().isActive) {
2792
+ if (status().isActive && newSlideLevel !== oldSlideLevel) {
2790
2793
  onActiveCallbacks.forEach(function (cb) {
2791
2794
  return cb();
2792
2795
  });
@@ -3237,7 +3240,11 @@ function EmbeddedEntityInline(props) {
3237
3240
 
3238
3241
  function handleEditClick() {
3239
3242
  return sdk.navigator.openEntry(entryId, {
3240
- slideIn: true
3243
+ slideIn: {
3244
+ waitForClose: true
3245
+ }
3246
+ }).then(function () {
3247
+ editor && focus(editor);
3241
3248
  });
3242
3249
  }
3243
3250
 
@@ -3276,7 +3283,7 @@ function selectEntityAndInsert$1(_x, _x2, _x3) {
3276
3283
 
3277
3284
  function _selectEntityAndInsert$1() {
3278
3285
  _selectEntityAndInsert$1 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(editor, sdk, logAction) {
3279
- var config, selection, entry, inlineEntryNode;
3286
+ var config, rteSlide, entry;
3280
3287
  return runtime_1.wrap(function _callee2$(_context2) {
3281
3288
  while (1) {
3282
3289
  switch (_context2.prev = _context2.next) {
@@ -3287,39 +3294,30 @@ function _selectEntityAndInsert$1() {
3287
3294
  config = _extends({}, newEntitySelectorConfigFromRichTextField(sdk.field, INLINES.EMBEDDED_ENTRY), {
3288
3295
  withCreate: true
3289
3296
  });
3290
- selection = editor.selection;
3297
+ rteSlide = watchCurrentSlide(sdk.navigator);
3291
3298
  _context2.next = 5;
3292
3299
  return sdk.dialogs.selectSingleEntry(config);
3293
3300
 
3294
3301
  case 5:
3295
3302
  entry = _context2.sent;
3296
- focus(editor); // Dialog steals focus from editor, return it.
3297
3303
 
3298
- if (entry) {
3299
- _context2.next = 10;
3300
- break;
3304
+ if (!entry) {
3305
+ logAction('cancelCreateEmbedDialog', {
3306
+ nodeType: INLINES.EMBEDDED_ENTRY
3307
+ });
3308
+ } else {
3309
+ insertNodes(editor, createInlineEntryNode$1(entry.sys.id));
3310
+ logAction('insert', {
3311
+ nodeType: INLINES.EMBEDDED_ENTRY
3312
+ });
3301
3313
  }
3302
3314
 
3303
- logAction('cancelCreateEmbedDialog', {
3304
- nodeType: INLINES.EMBEDDED_ENTRY
3315
+ rteSlide.onActive(function () {
3316
+ rteSlide.unwatch();
3317
+ focus(editor);
3305
3318
  });
3306
- return _context2.abrupt("return");
3307
-
3308
- case 10:
3309
- inlineEntryNode = createInlineEntryNode$1(entry.sys.id);
3310
- logAction('insert', {
3311
- nodeType: INLINES.EMBEDDED_ENTRY
3312
- }); // Got to wait until focus is really back on the editor or setSelection() won't work.
3313
-
3314
- return _context2.abrupt("return", new Promise(function (resolve) {
3315
- setTimeout(function () {
3316
- setSelection(editor, selection);
3317
- insertNodes(editor, inlineEntryNode);
3318
- resolve();
3319
- }, 0);
3320
- }));
3321
3319
 
3322
- case 13:
3320
+ case 8:
3323
3321
  case "end":
3324
3322
  return _context2.stop();
3325
3323
  }