@contentful/field-editor-rich-text 2.1.0 → 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 +14 -0
- package/dist/field-editor-rich-text.cjs.development.js +41 -22
- 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 +41 -22
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/helpers/removeInternalMarks.d.ts +1 -0
- package/dist/plugins/CommandPalette/components/CommandList.d.ts +1 -1
- package/dist/plugins/CommandPalette/hooks/useCommandList.d.ts +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
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
|
+
|
|
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)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @contentful/field-editor-rich-text
|
|
15
|
+
|
|
16
|
+
## [2.1.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@2.1.0...@contentful/field-editor-rich-text@2.1.1) (2022-07-05)
|
|
17
|
+
|
|
18
|
+
**Note:** Version bump only for package @contentful/field-editor-rich-text
|
|
19
|
+
|
|
6
20
|
# [2.1.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@2.0.4...@contentful/field-editor-rich-text@2.1.0) (2022-07-01)
|
|
7
21
|
|
|
8
22
|
### Features
|
|
@@ -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,17 +1888,21 @@ 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,
|
|
1893
|
+
|
|
1894
|
+
/* eslint-disable-next-line jsx-a11y/no-autofocus -- we want to keep focus on text input*/
|
|
1879
1895
|
autoFocus: false
|
|
1880
1896
|
}, /*#__PURE__*/React.createElement(f36Components.Popover.Trigger, null, /*#__PURE__*/React.createElement("span", null)), /*#__PURE__*/React.createElement(f36Components.Popover.Content, {
|
|
1881
|
-
className: styles.menuContent
|
|
1897
|
+
className: styles.menuContent,
|
|
1898
|
+
testId: "rich-text-commands"
|
|
1882
1899
|
}, /*#__PURE__*/React.createElement("header", {
|
|
1883
1900
|
className: styles.menuHeader
|
|
1884
1901
|
}, /*#__PURE__*/React.createElement(f36Components.SectionHeading, {
|
|
1885
1902
|
marginBottom: "none"
|
|
1886
1903
|
}, "Richtext commands")), /*#__PURE__*/React.createElement("div", {
|
|
1887
|
-
className: styles.menuList
|
|
1904
|
+
className: styles.menuList,
|
|
1905
|
+
"data-test-id": "rich-text-commands-list"
|
|
1888
1906
|
}, /*#__PURE__*/React.createElement(CommandListItems, {
|
|
1889
1907
|
commandItems: commandItems,
|
|
1890
1908
|
selectedItem: selectedItem
|
|
@@ -7378,24 +7396,13 @@ var StickyToolbarWrapper = function StickyToolbarWrapper(_ref) {
|
|
|
7378
7396
|
}, children);
|
|
7379
7397
|
};
|
|
7380
7398
|
|
|
7381
|
-
|
|
7382
|
-
* Returns whether a given operation is relevant enough to trigger a save.
|
|
7383
|
-
*/
|
|
7384
|
-
|
|
7385
|
-
var isRelevantOperation = function isRelevantOperation(op) {
|
|
7386
|
-
if (op.type === 'set_selection') {
|
|
7387
|
-
return false;
|
|
7388
|
-
}
|
|
7389
|
-
|
|
7390
|
-
return true;
|
|
7391
|
-
};
|
|
7392
|
-
|
|
7399
|
+
var internalMarks = [COMMAND_PROMPT];
|
|
7393
7400
|
var removeInternalMarks = function removeInternalMarks(document) {
|
|
7394
7401
|
return _extends({}, document, {
|
|
7395
7402
|
content: document.content.map(function (node) {
|
|
7396
7403
|
if (node.nodeType === 'text') {
|
|
7397
7404
|
node.marks = node.marks.filter(function (mark) {
|
|
7398
|
-
return mark.type
|
|
7405
|
+
return !internalMarks.includes(mark.type);
|
|
7399
7406
|
});
|
|
7400
7407
|
return node;
|
|
7401
7408
|
}
|
|
@@ -7405,6 +7412,18 @@ var removeInternalMarks = function removeInternalMarks(document) {
|
|
|
7405
7412
|
});
|
|
7406
7413
|
};
|
|
7407
7414
|
|
|
7415
|
+
/**
|
|
7416
|
+
* Returns whether a given operation is relevant enough to trigger a save.
|
|
7417
|
+
*/
|
|
7418
|
+
|
|
7419
|
+
var isRelevantOperation = function isRelevantOperation(op) {
|
|
7420
|
+
if (op.type === 'set_selection') {
|
|
7421
|
+
return false;
|
|
7422
|
+
}
|
|
7423
|
+
|
|
7424
|
+
return true;
|
|
7425
|
+
};
|
|
7426
|
+
|
|
7408
7427
|
var useOnValueChanged = function useOnValueChanged(_ref) {
|
|
7409
7428
|
var editorId = _ref.editorId,
|
|
7410
7429
|
handler = _ref.handler,
|