@contentful/field-editor-rich-text 3.4.5 → 3.4.6

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.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.4.5...@contentful/field-editor-rich-text@3.4.6) (2023-02-13)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **rte:** [TOL-960] conditional command palette plugin enablement ([#1342](https://github.com/contentful/field-editors/issues/1342)) ([0dfcf99](https://github.com/contentful/field-editors/commit/0dfcf9925af44bd045c3a0eb869ec9db787afa4a))
11
+
6
12
  ## [3.4.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.4.4...@contentful/field-editor-rich-text@3.4.5) (2023-02-07)
7
13
 
8
14
  ### Bug Fixes
@@ -1920,12 +1920,39 @@ var removeQuery = function removeQuery(editor) {
1920
1920
  }
1921
1921
  };
1922
1922
 
1923
+ function isCommandPromptPluginEnabled(sdk) {
1924
+ var inlineAllowed = isNodeTypeEnabled(sdk.field, Contentful.INLINES.EMBEDDED_ENTRY);
1925
+ var entriesAllowed = isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.EMBEDDED_ENTRY);
1926
+ var assetsAllowed = isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.EMBEDDED_ASSET);
1927
+ return {
1928
+ inlineAllowed: inlineAllowed,
1929
+ entriesAllowed: entriesAllowed,
1930
+ assetsAllowed: assetsAllowed
1931
+ };
1932
+ }
1933
+
1934
+ function getCommandPermissions(sdk, editor) {
1935
+ var canInsertBlocks = !isNodeTypeSelected(editor, Contentful.BLOCKS.TABLE);
1936
+
1937
+ var _isCommandPromptPlugi = isCommandPromptPluginEnabled(sdk),
1938
+ inlineAllowed = _isCommandPromptPlugi.inlineAllowed,
1939
+ entriesAllowed = _isCommandPromptPlugi.entriesAllowed,
1940
+ assetsAllowed = _isCommandPromptPlugi.assetsAllowed;
1941
+
1942
+ return {
1943
+ inlineAllowed: inlineAllowed,
1944
+ entriesAllowed: entriesAllowed && canInsertBlocks,
1945
+ assetsAllowed: assetsAllowed && canInsertBlocks
1946
+ };
1947
+ }
1948
+
1923
1949
  var useCommands = function useCommands(sdk, query, editor) {
1924
1950
  var contentTypes = sdk.space.getCachedContentTypes();
1925
- var canInsertBlocks = !isNodeTypeSelected(editor, Contentful.BLOCKS.TABLE);
1926
- var inlineAllowed = isNodeTypeEnabled(sdk.field, Contentful.INLINES.EMBEDDED_ENTRY);
1927
- var entriesAllowed = isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.EMBEDDED_ENTRY) && canInsertBlocks;
1928
- var assetsAllowed = isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.EMBEDDED_ASSET) && canInsertBlocks;
1951
+
1952
+ var _getCommandPermission = getCommandPermissions(sdk, editor),
1953
+ inlineAllowed = _getCommandPermission.inlineAllowed,
1954
+ entriesAllowed = _getCommandPermission.entriesAllowed,
1955
+ assetsAllowed = _getCommandPermission.assetsAllowed;
1929
1956
 
1930
1957
  var _useState = React.useState(function () {
1931
1958
  var getEmbedEntry = function getEmbedEntry(contentType) {
@@ -7514,14 +7541,14 @@ var getPlugins = function getPlugins(sdk, onAction, restrictedMarks) {
7514
7541
  return [// AST must come after the HTML deserializer
7515
7542
  p.createDeserializeHtmlPlugin(), p.createDeserializeAstPlugin(), plateSerializerDocx.createDeserializeDocxPlugin(), // Tracking - This should come first so all plugins below will have access to `editor.tracking`
7516
7543
  createTrackingPlugin(onAction), // Global / Global shortcuts
7517
- createDragAndDropPlugin(), createCommandPalettePlugin(), // Block Elements
7544
+ createDragAndDropPlugin()].concat(Object.values(isCommandPromptPluginEnabled(sdk)).some(Boolean) ? [createCommandPalettePlugin()] : [], [// Block Elements
7518
7545
  createParagraphPlugin(), createListPlugin(), createHrPlugin(), createHeadingPlugin(), createQuotePlugin(), createTablePlugin(), createEmbeddedEntryBlockPlugin(sdk), createEmbeddedAssetBlockPlugin(sdk), // Inline elements
7519
7546
  createHyperlinkPlugin(sdk), createEmbeddedEntityInlinePlugin(sdk), // Marks
7520
7547
  createMarksPlugin(), // Other
7521
7548
  createTrailingParagraphPlugin(), createTextPlugin(restrictedMarks), createVoidsPlugin(), createSelectOnBackspacePlugin(), // Pasting content from other sources
7522
7549
  createPasteHTMLPlugin(), // These plugins drive their configurations from the list of plugins
7523
7550
  // above. They MUST come last.
7524
- createSoftBreakPlugin(), createExitBreakPlugin(), createResetNodePlugin(), createNormalizerPlugin()];
7551
+ createSoftBreakPlugin(), createExitBreakPlugin(), createResetNodePlugin(), createNormalizerPlugin()]);
7525
7552
  };
7526
7553
  var disableCorePlugins = {
7527
7554
  // Temporarily until the upstream issue is fixed.