@contentful/field-editor-rich-text 0.25.0-next → 0.26.3-next

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.
@@ -680,6 +680,7 @@ var VALIDATIONS = {
680
680
  ENABLED_MARKS: 'enabledMarks',
681
681
  ENABLED_NODE_TYPES: 'enabledNodeTypes'
682
682
  };
683
+ var DEFAULT_ENABLED_NODE_TYPES = [Contentful.BLOCKS.DOCUMENT, Contentful.BLOCKS.PARAGRAPH, 'text'];
683
684
 
684
685
  var getRichTextValidation = function getRichTextValidation(field, validationType) {
685
686
  return flow(function (v) {
@@ -690,13 +691,14 @@ var getRichTextValidation = function getRichTextValidation(field, validationType
690
691
  };
691
692
 
692
693
  var isFormattingOptionEnabled = function isFormattingOptionEnabled(field, validationType, nodeTypeOrMark) {
693
- var enabledFormattings = getRichTextValidation(field, validationType);
694
+ var enabledFormattings = getRichTextValidation(field, validationType); // TODO: In the future, validations will always be opt-in. In that case
695
+ // we don't need this step.
694
696
 
695
697
  if (enabledFormattings === undefined) {
696
698
  return true;
697
699
  }
698
700
 
699
- return enabledFormattings.includes(nodeTypeOrMark);
701
+ return DEFAULT_ENABLED_NODE_TYPES.concat(enabledFormattings).includes(nodeTypeOrMark);
700
702
  };
701
703
 
702
704
  var isNodeTypeEnabled = function isNodeTypeEnabled(field, nodeType) {
@@ -2426,13 +2428,17 @@ function FetchingWrappedEntryCard(props) {
2426
2428
 
2427
2429
  var entry = entries[props.entryId];
2428
2430
  var contentType = React.useMemo(function () {
2431
+ if (!entry || entry === 'failed') {
2432
+ return undefined;
2433
+ }
2434
+
2429
2435
  return props.sdk.space.getCachedContentTypes().find(function (contentType) {
2430
- return contentType.sys.id === (entry == null ? void 0 : entry.sys.contentType.sys.id);
2436
+ return contentType.sys.id === entry.sys.contentType.sys.id;
2431
2437
  });
2432
2438
  }, [props.sdk, entry]);
2433
2439
  var defaultLocaleCode = props.sdk.locales["default"];
2434
2440
  React.useEffect(function () {
2435
- if (!entry) return;
2441
+ if (!entry || entry === 'failed') return;
2436
2442
  fieldEditorShared.entityHelpers.getEntryImage({
2437
2443
  entry: entry,
2438
2444
  contentType: contentType,
@@ -2564,13 +2570,15 @@ function AssetDropdownMenu(_ref) {
2564
2570
  }
2565
2571
 
2566
2572
  function FetchingWrappedAssetCard(props) {
2573
+ var _asset$fields;
2574
+
2567
2575
  var _useEntities = fieldEditorReference.useEntities(),
2568
2576
  getOrLoadAsset = _useEntities.getOrLoadAsset,
2569
2577
  assets = _useEntities.assets;
2570
2578
 
2571
2579
  var asset = assets[props.assetId];
2572
2580
  var defaultLocaleCode = props.sdk.locales["default"];
2573
- var entityFile = asset != null && asset.fields.file ? asset.fields.file[props.locale] || asset.fields.file[defaultLocaleCode] : undefined;
2581
+ var entityFile = asset != null && (_asset$fields = asset.fields) != null && _asset$fields.file ? asset.fields.file[props.locale] || asset.fields.file[defaultLocaleCode] : undefined;
2574
2582
  React.useEffect(function () {
2575
2583
  getOrLoadAsset(props.assetId);
2576
2584
  }, [props.assetId]); // eslint-disable-line
@@ -3706,6 +3714,8 @@ function addTableTrackingEvents(editor, _ref) {
3706
3714
  });
3707
3715
  }
3708
3716
  }, 1);
3717
+ } else {
3718
+ insertData(data);
3709
3719
  }
3710
3720
  };
3711
3721
  }
@@ -4300,7 +4310,7 @@ function FetchingWrappedInlineEntryCard(props) {
4300
4310
  }, [entries, props.entryId]);
4301
4311
  var allContentTypes = props.sdk.space.getCachedContentTypes();
4302
4312
  var contentType = React__default.useMemo(function () {
4303
- if (!entry || !allContentTypes) return undefined;
4313
+ if (!entry || entry === 'failed' || !allContentTypes) return undefined;
4304
4314
  return allContentTypes.find(function (contentType) {
4305
4315
  return contentType.sys.id === entry.sys.contentType.sys.id;
4306
4316
  });
@@ -4884,6 +4894,8 @@ function withPasteHandling(editor) {
4884
4894
  var sanitized = sanitizeHtml(html, editor);
4885
4895
  var newData = htmlToDataTransfer(sanitized);
4886
4896
  insertData(newData);
4897
+ } else {
4898
+ insertData(data);
4887
4899
  }
4888
4900
  };
4889
4901
  };