@contentful/field-editor-rich-text 2.1.2 → 2.1.3
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 +21 -7
- 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 +21 -7
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/plugins/CommandPalette/components/CommandList.d.ts +1 -1
- package/dist/plugins/CommandPalette/hooks/useCommandList.d.ts +1 -0
- 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
|
+
## [2.1.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@2.1.2...@contentful/field-editor-rich-text@2.1.3) (2022-07-06)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- rt-commands palette closes on click outside ([#1175](https://github.com/contentful/field-editors/issues/1175)) ([b9dd434](https://github.com/contentful/field-editors/commit/b9dd43497a874b35318230074d7de411012c7eee))
|
|
11
|
+
|
|
6
12
|
## [2.1.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@2.1.1...@contentful/field-editor-rich-text@2.1.2) (2022-07-06)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @contentful/field-editor-rich-text
|
|
@@ -584,6 +584,10 @@ var useCommandList = function useCommandList(commandItems, container) {
|
|
|
584
584
|
selectedItem = _React$useState[0],
|
|
585
585
|
setSelectedItem = _React$useState[1];
|
|
586
586
|
|
|
587
|
+
var _React$useState2 = React.useState(commandItems.length > 0),
|
|
588
|
+
isOpen = _React$useState2[0],
|
|
589
|
+
setIsOpen = _React$useState2[1];
|
|
590
|
+
|
|
587
591
|
React.useEffect(function () {
|
|
588
592
|
if (!(container != null && container.current)) {
|
|
589
593
|
return;
|
|
@@ -648,8 +652,21 @@ var useCommandList = function useCommandList(commandItems, container) {
|
|
|
648
652
|
return window.removeEventListener('keydown', handleKeyDown);
|
|
649
653
|
};
|
|
650
654
|
}, [commandItems, container, selectedItem]);
|
|
655
|
+
React.useEffect(function () {
|
|
656
|
+
var handleClick = function handleClick(event) {
|
|
657
|
+
if (container.current && !container.current.contains(event.target)) {
|
|
658
|
+
setIsOpen(false);
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
document.addEventListener('click', handleClick);
|
|
663
|
+
return function () {
|
|
664
|
+
document.removeEventListener('click', handleClick);
|
|
665
|
+
};
|
|
666
|
+
}, [container]);
|
|
651
667
|
return {
|
|
652
|
-
selectedItem: selectedItem
|
|
668
|
+
selectedItem: selectedItem,
|
|
669
|
+
isOpen: isOpen
|
|
653
670
|
};
|
|
654
671
|
};
|
|
655
672
|
|
|
@@ -1858,11 +1875,8 @@ var CommandList = function CommandList(_ref5) {
|
|
|
1858
1875
|
var commandItems = useCommands(sdk, query, editor);
|
|
1859
1876
|
|
|
1860
1877
|
var _useCommandList = useCommandList(commandItems, container),
|
|
1861
|
-
selectedItem = _useCommandList.selectedItem
|
|
1862
|
-
|
|
1863
|
-
if (commandItems.length === 0) {
|
|
1864
|
-
return null;
|
|
1865
|
-
}
|
|
1878
|
+
selectedItem = _useCommandList.selectedItem,
|
|
1879
|
+
isOpen = _useCommandList.isOpen;
|
|
1866
1880
|
|
|
1867
1881
|
return /*#__PURE__*/React.createElement("div", {
|
|
1868
1882
|
className: styles.container,
|
|
@@ -1874,7 +1888,7 @@ var CommandList = function CommandList(_ref5) {
|
|
|
1874
1888
|
}, /*#__PURE__*/React.createElement(f36Components.ScreenReaderOnly, null, "Richtext commands. Currently focused item: ", selectedItem, ". Press ", /*#__PURE__*/React.createElement("kbd", null, "enter"), " to select, ", /*#__PURE__*/React.createElement("kbd", null, "arrows"), " to navigate, ", /*#__PURE__*/React.createElement("kbd", null, "escape"), " to close.")), /*#__PURE__*/React.createElement("div", {
|
|
1875
1889
|
"aria-hidden": true
|
|
1876
1890
|
}, /*#__PURE__*/React.createElement(f36Components.Popover, {
|
|
1877
|
-
isOpen:
|
|
1891
|
+
isOpen: isOpen,
|
|
1878
1892
|
usePortal: false,
|
|
1879
1893
|
|
|
1880
1894
|
/* eslint-disable-next-line jsx-a11y/no-autofocus -- we want to keep focus on text input*/
|