@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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.4.9](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.4.8...@contentful/field-editor-rich-text@3.4.9) (2023-03-03)
7
+
8
+ ### Bug Fixes
9
+
10
+ - 🐛 do not focus RTE on inline embed + create entry ([#1354](https://github.com/contentful/field-editors/issues/1354)) ([3c54787](https://github.com/contentful/field-editors/commit/3c54787d740f7220e55976bac97fb8d542f26d4d))
11
+
6
12
  ## [3.4.8](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.4.7...@contentful/field-editor-rich-text@3.4.8) (2023-03-01)
7
13
 
8
14
  ### Bug Fixes
@@ -2779,21 +2779,24 @@ function watchCurrentSlide(navigator) {
2779
2779
  };
2780
2780
  };
2781
2781
 
2782
- var off = navigator.onSlideInNavigation(function (info) {
2782
+ var off = navigator.onSlideInNavigation(function (_ref) {
2783
+ var oldSlideLevel = _ref.oldSlideLevel,
2784
+ newSlideLevel = _ref.newSlideLevel;
2785
+
2783
2786
  if (initialSlideLevel === undefined) {
2784
- initialSlideLevel = info.oldSlideLevel;
2787
+ initialSlideLevel = oldSlideLevel;
2785
2788
  }
2786
2789
 
2787
- lastSlideLevel = info.newSlideLevel;
2790
+ lastSlideLevel = newSlideLevel;
2788
2791
 
2789
- if (info.newSlideLevel < initialSlideLevel) {
2792
+ if (newSlideLevel < initialSlideLevel) {
2790
2793
  wasSlideClosed = true;
2791
2794
  off(); // No more point in watching, slide got closed.
2792
2795
 
2793
2796
  onActiveCallbacks.clear();
2794
2797
  }
2795
2798
 
2796
- if (status().isActive) {
2799
+ if (status().isActive && newSlideLevel !== oldSlideLevel) {
2797
2800
  onActiveCallbacks.forEach(function (cb) {
2798
2801
  return cb();
2799
2802
  });
@@ -3244,7 +3247,11 @@ function EmbeddedEntityInline(props) {
3244
3247
 
3245
3248
  function handleEditClick() {
3246
3249
  return sdk.navigator.openEntry(entryId, {
3247
- slideIn: true
3250
+ slideIn: {
3251
+ waitForClose: true
3252
+ }
3253
+ }).then(function () {
3254
+ editor && focus(editor);
3248
3255
  });
3249
3256
  }
3250
3257
 
@@ -3283,7 +3290,7 @@ function selectEntityAndInsert$1(_x, _x2, _x3) {
3283
3290
 
3284
3291
  function _selectEntityAndInsert$1() {
3285
3292
  _selectEntityAndInsert$1 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(editor, sdk, logAction) {
3286
- var config, selection, entry, inlineEntryNode;
3293
+ var config, rteSlide, entry;
3287
3294
  return runtime_1.wrap(function _callee2$(_context2) {
3288
3295
  while (1) {
3289
3296
  switch (_context2.prev = _context2.next) {
@@ -3294,39 +3301,30 @@ function _selectEntityAndInsert$1() {
3294
3301
  config = _extends({}, newEntitySelectorConfigFromRichTextField(sdk.field, Contentful.INLINES.EMBEDDED_ENTRY), {
3295
3302
  withCreate: true
3296
3303
  });
3297
- selection = editor.selection;
3304
+ rteSlide = watchCurrentSlide(sdk.navigator);
3298
3305
  _context2.next = 5;
3299
3306
  return sdk.dialogs.selectSingleEntry(config);
3300
3307
 
3301
3308
  case 5:
3302
3309
  entry = _context2.sent;
3303
- focus(editor); // Dialog steals focus from editor, return it.
3304
3310
 
3305
- if (entry) {
3306
- _context2.next = 10;
3307
- break;
3311
+ if (!entry) {
3312
+ logAction('cancelCreateEmbedDialog', {
3313
+ nodeType: Contentful.INLINES.EMBEDDED_ENTRY
3314
+ });
3315
+ } else {
3316
+ insertNodes(editor, createInlineEntryNode$1(entry.sys.id));
3317
+ logAction('insert', {
3318
+ nodeType: Contentful.INLINES.EMBEDDED_ENTRY
3319
+ });
3308
3320
  }
3309
3321
 
3310
- logAction('cancelCreateEmbedDialog', {
3311
- nodeType: Contentful.INLINES.EMBEDDED_ENTRY
3322
+ rteSlide.onActive(function () {
3323
+ rteSlide.unwatch();
3324
+ focus(editor);
3312
3325
  });
3313
- return _context2.abrupt("return");
3314
-
3315
- case 10:
3316
- inlineEntryNode = createInlineEntryNode$1(entry.sys.id);
3317
- logAction('insert', {
3318
- nodeType: Contentful.INLINES.EMBEDDED_ENTRY
3319
- }); // Got to wait until focus is really back on the editor or setSelection() won't work.
3320
-
3321
- return _context2.abrupt("return", new Promise(function (resolve) {
3322
- setTimeout(function () {
3323
- setSelection(editor, selection);
3324
- insertNodes(editor, inlineEntryNode);
3325
- resolve();
3326
- }, 0);
3327
- }));
3328
3326
 
3329
- case 13:
3327
+ case 8:
3330
3328
  case "end":
3331
3329
  return _context2.stop();
3332
3330
  }