@contentful/field-editor-rich-text 2.1.1 → 2.2.0
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 +16 -0
- package/dist/field-editor-rich-text.cjs.development.js +32 -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 +32 -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/dist/plugins/Tracking/createTrackingPlugin.d.ts +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.2.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@2.1.3...@contentful/field-editor-rich-text@2.2.0) (2022-07-06)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- add tracking for rich-text-commands ([#1174](https://github.com/contentful/field-editors/issues/1174)) ([75fc492](https://github.com/contentful/field-editors/commit/75fc49210a5789bf029ddb81413349d74f441f28))
|
|
11
|
+
|
|
12
|
+
## [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)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- 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))
|
|
17
|
+
|
|
18
|
+
## [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)
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @contentful/field-editor-rich-text
|
|
21
|
+
|
|
6
22
|
## [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)
|
|
7
23
|
|
|
8
24
|
**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
|
|
|
@@ -1592,6 +1609,9 @@ var useCommands = function useCommands(sdk, query, editor) {
|
|
|
1592
1609
|
editor.insertSoftBreak();
|
|
1593
1610
|
insertBlock(editor, Contentful.BLOCKS.EMBEDDED_ENTRY, entry.entry);
|
|
1594
1611
|
slate.Transforms.select(editor, selection);
|
|
1612
|
+
editor.tracking.onCommandPaletteAction('insert', {
|
|
1613
|
+
nodeType: Contentful.BLOCKS.EMBEDDED_ENTRY
|
|
1614
|
+
});
|
|
1595
1615
|
}
|
|
1596
1616
|
}
|
|
1597
1617
|
};
|
|
@@ -1621,6 +1641,9 @@ var useCommands = function useCommands(sdk, query, editor) {
|
|
|
1621
1641
|
removeCommand(editor);
|
|
1622
1642
|
slate.Transforms.insertNodes(editor, inlineNode);
|
|
1623
1643
|
editor.insertText('');
|
|
1644
|
+
editor.tracking.onCommandPaletteAction('insert', {
|
|
1645
|
+
nodeType: Contentful.INLINES.EMBEDDED_ENTRY
|
|
1646
|
+
});
|
|
1624
1647
|
}
|
|
1625
1648
|
};
|
|
1626
1649
|
}));
|
|
@@ -1658,6 +1681,9 @@ var useCommands = function useCommands(sdk, query, editor) {
|
|
|
1658
1681
|
editor.insertSoftBreak();
|
|
1659
1682
|
insertBlock(editor, Contentful.BLOCKS.EMBEDDED_ASSET, asset.entity);
|
|
1660
1683
|
slate.Transforms.select(editor, selection);
|
|
1684
|
+
editor.tracking.onCommandPaletteAction('insert', {
|
|
1685
|
+
nodeType: Contentful.BLOCKS.EMBEDDED_ASSET
|
|
1686
|
+
});
|
|
1661
1687
|
}
|
|
1662
1688
|
}
|
|
1663
1689
|
};
|
|
@@ -1858,11 +1884,8 @@ var CommandList = function CommandList(_ref5) {
|
|
|
1858
1884
|
var commandItems = useCommands(sdk, query, editor);
|
|
1859
1885
|
|
|
1860
1886
|
var _useCommandList = useCommandList(commandItems, container),
|
|
1861
|
-
selectedItem = _useCommandList.selectedItem
|
|
1862
|
-
|
|
1863
|
-
if (commandItems.length === 0) {
|
|
1864
|
-
return null;
|
|
1865
|
-
}
|
|
1887
|
+
selectedItem = _useCommandList.selectedItem,
|
|
1888
|
+
isOpen = _useCommandList.isOpen;
|
|
1866
1889
|
|
|
1867
1890
|
return /*#__PURE__*/React.createElement("div", {
|
|
1868
1891
|
className: styles.container,
|
|
@@ -1874,7 +1897,7 @@ var CommandList = function CommandList(_ref5) {
|
|
|
1874
1897
|
}, /*#__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
1898
|
"aria-hidden": true
|
|
1876
1899
|
}, /*#__PURE__*/React.createElement(f36Components.Popover, {
|
|
1877
|
-
isOpen:
|
|
1900
|
+
isOpen: isOpen,
|
|
1878
1901
|
usePortal: false,
|
|
1879
1902
|
|
|
1880
1903
|
/* eslint-disable-next-line jsx-a11y/no-autofocus -- we want to keep focus on text input*/
|
|
@@ -1922,6 +1945,7 @@ var createOnKeyDown = function createOnKeyDown() {
|
|
|
1922
1945
|
var _setMarks;
|
|
1923
1946
|
|
|
1924
1947
|
plateCore.setMarks(editor, (_setMarks = {}, _setMarks[COMMAND_PROMPT] = true, _setMarks));
|
|
1948
|
+
editor.tracking.onCommandPaletteAction('openRichTextCommandPalette');
|
|
1925
1949
|
}
|
|
1926
1950
|
|
|
1927
1951
|
var isActive = plateCore.isMarkActive(editor, COMMAND_PROMPT);
|
|
@@ -1951,6 +1975,7 @@ var createOnKeyDown = function createOnKeyDown() {
|
|
|
1951
1975
|
key: COMMAND_PROMPT,
|
|
1952
1976
|
at: _range
|
|
1953
1977
|
});
|
|
1978
|
+
editor.tracking.onCommandPaletteAction('cancelRichTextCommandPalette');
|
|
1954
1979
|
}
|
|
1955
1980
|
}
|
|
1956
1981
|
};
|