@contentful/field-editor-rich-text 3.4.7 → 3.4.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/CHANGELOG.md +6 -0
- package/dist/field-editor-rich-text.cjs.development.js +96 -19
- 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 +96 -19
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/helpers/sdkNavigatorSlideIn.d.ts +16 -0
- package/dist/test-utils/jsx.d.ts +1 -1
- package/package.json +2 -2
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.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
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- do not focus RTE when another slide is open [TOL-989] ([#1353](https://github.com/contentful/field-editors/issues/1353)) ([db07c18](https://github.com/contentful/field-editors/commit/db07c180ab1e9bbd197f8b4b5eb74c1e0b5e251d))
|
|
11
|
+
|
|
6
12
|
## [3.4.7](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.4.6...@contentful/field-editor-rich-text@3.4.7) (2023-02-21)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @contentful/field-editor-rich-text
|
|
@@ -2758,13 +2758,91 @@ function getEntityTypeFromRichTextNode(nodeType) {
|
|
|
2758
2758
|
throw new Error("RichText node type `" + nodeType + "` has no associated `entityType`");
|
|
2759
2759
|
}
|
|
2760
2760
|
|
|
2761
|
+
/**
|
|
2762
|
+
* Allows to observe when the current slide-in navigation slide gets e.g.
|
|
2763
|
+
* re-activated after opening another slide on top. This is useful as the sdk
|
|
2764
|
+
* does not give full insights into e.g. whether sdk.dialogs.selectSingleEntry()
|
|
2765
|
+
* with `withCreate: true` option opens the slide-in navigation to edit the
|
|
2766
|
+
* created entry after returning it.
|
|
2767
|
+
*/
|
|
2768
|
+
|
|
2769
|
+
function watchCurrentSlide(navigator) {
|
|
2770
|
+
var onActiveCallbacks = new Set();
|
|
2771
|
+
var wasSlideClosed = false;
|
|
2772
|
+
var initialSlideLevel;
|
|
2773
|
+
var lastSlideLevel;
|
|
2774
|
+
|
|
2775
|
+
var status = function status() {
|
|
2776
|
+
return {
|
|
2777
|
+
wasClosed: wasSlideClosed,
|
|
2778
|
+
isActive: !wasSlideClosed && lastSlideLevel === initialSlideLevel
|
|
2779
|
+
};
|
|
2780
|
+
};
|
|
2781
|
+
|
|
2782
|
+
var off = navigator.onSlideInNavigation(function (info) {
|
|
2783
|
+
if (initialSlideLevel === undefined) {
|
|
2784
|
+
initialSlideLevel = info.oldSlideLevel;
|
|
2785
|
+
}
|
|
2786
|
+
|
|
2787
|
+
lastSlideLevel = info.newSlideLevel;
|
|
2788
|
+
|
|
2789
|
+
if (info.newSlideLevel < initialSlideLevel) {
|
|
2790
|
+
wasSlideClosed = true;
|
|
2791
|
+
off(); // No more point in watching, slide got closed.
|
|
2792
|
+
|
|
2793
|
+
onActiveCallbacks.clear();
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
if (status().isActive) {
|
|
2797
|
+
onActiveCallbacks.forEach(function (cb) {
|
|
2798
|
+
return cb();
|
|
2799
|
+
});
|
|
2800
|
+
}
|
|
2801
|
+
});
|
|
2802
|
+
/**
|
|
2803
|
+
* Call to unsubscribe from navigator events when the watcher is no longer
|
|
2804
|
+
* needed.
|
|
2805
|
+
*/
|
|
2806
|
+
|
|
2807
|
+
function unwatch() {
|
|
2808
|
+
off();
|
|
2809
|
+
onActiveCallbacks.clear();
|
|
2810
|
+
}
|
|
2811
|
+
/**
|
|
2812
|
+
* Fires immediately when the slide is currently active, or at the point when
|
|
2813
|
+
* it becomes active again, if there are slides on top that get closed. Does not
|
|
2814
|
+
* fire when the observed slide gets closed, and then re-opened through browser
|
|
2815
|
+
* back, as this technically opens a new slide and editor instance.
|
|
2816
|
+
*/
|
|
2817
|
+
|
|
2818
|
+
|
|
2819
|
+
function onActive(cb) {
|
|
2820
|
+
if (wasSlideClosed) return noop; // Can't re-activate already closed slide.
|
|
2821
|
+
|
|
2822
|
+
if (status().isActive) {
|
|
2823
|
+
cb();
|
|
2824
|
+
}
|
|
2825
|
+
|
|
2826
|
+
onActiveCallbacks.add(cb);
|
|
2827
|
+
return function () {
|
|
2828
|
+
return onActiveCallbacks["delete"](cb);
|
|
2829
|
+
};
|
|
2830
|
+
}
|
|
2831
|
+
|
|
2832
|
+
return {
|
|
2833
|
+
status: status,
|
|
2834
|
+
onActive: onActive,
|
|
2835
|
+
unwatch: unwatch
|
|
2836
|
+
};
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2761
2839
|
function selectEntityAndInsert(_x, _x2, _x3, _x4) {
|
|
2762
2840
|
return _selectEntityAndInsert.apply(this, arguments);
|
|
2763
2841
|
} // TODO: incorporate this logic inside the trailingParagraph plugin instead
|
|
2764
2842
|
|
|
2765
2843
|
function _selectEntityAndInsert() {
|
|
2766
2844
|
_selectEntityAndInsert = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(nodeType, sdk, editor, logAction) {
|
|
2767
|
-
var field, dialogs, baseConfig, selectEntity, config,
|
|
2845
|
+
var field, dialogs, baseConfig, selectEntity, config, rteSlide, entity;
|
|
2768
2846
|
return runtime_1.wrap(function _callee$(_context) {
|
|
2769
2847
|
while (1) {
|
|
2770
2848
|
switch (_context.prev = _context.next) {
|
|
@@ -2778,32 +2856,33 @@ function _selectEntityAndInsert() {
|
|
|
2778
2856
|
config = _extends({}, baseConfig, {
|
|
2779
2857
|
withCreate: true
|
|
2780
2858
|
});
|
|
2781
|
-
|
|
2859
|
+
rteSlide = watchCurrentSlide(sdk.navigator);
|
|
2782
2860
|
_context.next = 8;
|
|
2783
2861
|
return selectEntity(config);
|
|
2784
2862
|
|
|
2785
2863
|
case 8:
|
|
2786
2864
|
entity = _context.sent;
|
|
2787
2865
|
|
|
2788
|
-
if (entity) {
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2866
|
+
if (!entity) {
|
|
2867
|
+
logAction('cancelCreateEmbedDialog', {
|
|
2868
|
+
nodeType: nodeType
|
|
2869
|
+
});
|
|
2870
|
+
} else {
|
|
2871
|
+
insertBlock$1(editor, nodeType, entity);
|
|
2872
|
+
ensureFollowingParagraph(editor);
|
|
2873
|
+
logAction('insert', {
|
|
2874
|
+
nodeType: nodeType
|
|
2875
|
+
});
|
|
2876
|
+
} // If user chose to create a new entity, this might open slide-in to edit the
|
|
2877
|
+
// entity. In this case, no point in focusing RTE which is now in the slide below.
|
|
2792
2878
|
|
|
2793
|
-
logAction('cancelCreateEmbedDialog', {
|
|
2794
|
-
nodeType: nodeType
|
|
2795
|
-
});
|
|
2796
|
-
return _context.abrupt("return");
|
|
2797
2879
|
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
ensureFollowingParagraph(editor);
|
|
2802
|
-
logAction('insert', {
|
|
2803
|
-
nodeType: nodeType
|
|
2880
|
+
rteSlide.onActive(function () {
|
|
2881
|
+
rteSlide.unwatch();
|
|
2882
|
+
focus(editor);
|
|
2804
2883
|
});
|
|
2805
2884
|
|
|
2806
|
-
case
|
|
2885
|
+
case 11:
|
|
2807
2886
|
case "end":
|
|
2808
2887
|
return _context.stop();
|
|
2809
2888
|
}
|
|
@@ -2868,8 +2947,6 @@ function insertBlock$1(editor, nodeType, entity) {
|
|
|
2868
2947
|
} else {
|
|
2869
2948
|
setNodes(editor, linkedEntityBlock);
|
|
2870
2949
|
}
|
|
2871
|
-
|
|
2872
|
-
focus(editor);
|
|
2873
2950
|
}
|
|
2874
2951
|
|
|
2875
2952
|
var styles$2 = {
|