@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.
@@ -673,6 +673,7 @@ var VALIDATIONS = {
673
673
  ENABLED_MARKS: 'enabledMarks',
674
674
  ENABLED_NODE_TYPES: 'enabledNodeTypes'
675
675
  };
676
+ var DEFAULT_ENABLED_NODE_TYPES = [BLOCKS.DOCUMENT, BLOCKS.PARAGRAPH, 'text'];
676
677
 
677
678
  var getRichTextValidation = function getRichTextValidation(field, validationType) {
678
679
  return flow(function (v) {
@@ -683,13 +684,14 @@ var getRichTextValidation = function getRichTextValidation(field, validationType
683
684
  };
684
685
 
685
686
  var isFormattingOptionEnabled = function isFormattingOptionEnabled(field, validationType, nodeTypeOrMark) {
686
- var enabledFormattings = getRichTextValidation(field, validationType);
687
+ var enabledFormattings = getRichTextValidation(field, validationType); // TODO: In the future, validations will always be opt-in. In that case
688
+ // we don't need this step.
687
689
 
688
690
  if (enabledFormattings === undefined) {
689
691
  return true;
690
692
  }
691
693
 
692
- return enabledFormattings.includes(nodeTypeOrMark);
694
+ return DEFAULT_ENABLED_NODE_TYPES.concat(enabledFormattings).includes(nodeTypeOrMark);
693
695
  };
694
696
 
695
697
  var isNodeTypeEnabled = function isNodeTypeEnabled(field, nodeType) {
@@ -2419,13 +2421,17 @@ function FetchingWrappedEntryCard(props) {
2419
2421
 
2420
2422
  var entry = entries[props.entryId];
2421
2423
  var contentType = useMemo(function () {
2424
+ if (!entry || entry === 'failed') {
2425
+ return undefined;
2426
+ }
2427
+
2422
2428
  return props.sdk.space.getCachedContentTypes().find(function (contentType) {
2423
- return contentType.sys.id === (entry == null ? void 0 : entry.sys.contentType.sys.id);
2429
+ return contentType.sys.id === entry.sys.contentType.sys.id;
2424
2430
  });
2425
2431
  }, [props.sdk, entry]);
2426
2432
  var defaultLocaleCode = props.sdk.locales["default"];
2427
2433
  useEffect(function () {
2428
- if (!entry) return;
2434
+ if (!entry || entry === 'failed') return;
2429
2435
  entityHelpers.getEntryImage({
2430
2436
  entry: entry,
2431
2437
  contentType: contentType,
@@ -2557,13 +2563,15 @@ function AssetDropdownMenu(_ref) {
2557
2563
  }
2558
2564
 
2559
2565
  function FetchingWrappedAssetCard(props) {
2566
+ var _asset$fields;
2567
+
2560
2568
  var _useEntities = useEntities(),
2561
2569
  getOrLoadAsset = _useEntities.getOrLoadAsset,
2562
2570
  assets = _useEntities.assets;
2563
2571
 
2564
2572
  var asset = assets[props.assetId];
2565
2573
  var defaultLocaleCode = props.sdk.locales["default"];
2566
- var entityFile = asset != null && asset.fields.file ? asset.fields.file[props.locale] || asset.fields.file[defaultLocaleCode] : undefined;
2574
+ var entityFile = asset != null && (_asset$fields = asset.fields) != null && _asset$fields.file ? asset.fields.file[props.locale] || asset.fields.file[defaultLocaleCode] : undefined;
2567
2575
  useEffect(function () {
2568
2576
  getOrLoadAsset(props.assetId);
2569
2577
  }, [props.assetId]); // eslint-disable-line
@@ -3699,6 +3707,8 @@ function addTableTrackingEvents(editor, _ref) {
3699
3707
  });
3700
3708
  }
3701
3709
  }, 1);
3710
+ } else {
3711
+ insertData(data);
3702
3712
  }
3703
3713
  };
3704
3714
  }
@@ -4293,7 +4303,7 @@ function FetchingWrappedInlineEntryCard(props) {
4293
4303
  }, [entries, props.entryId]);
4294
4304
  var allContentTypes = props.sdk.space.getCachedContentTypes();
4295
4305
  var contentType = React__default.useMemo(function () {
4296
- if (!entry || !allContentTypes) return undefined;
4306
+ if (!entry || entry === 'failed' || !allContentTypes) return undefined;
4297
4307
  return allContentTypes.find(function (contentType) {
4298
4308
  return contentType.sys.id === entry.sys.contentType.sys.id;
4299
4309
  });
@@ -4877,6 +4887,8 @@ function withPasteHandling(editor) {
4877
4887
  var sanitized = sanitizeHtml(html, editor);
4878
4888
  var newData = htmlToDataTransfer(sanitized);
4879
4889
  insertData(newData);
4890
+ } else {
4891
+ insertData(data);
4880
4892
  }
4881
4893
  };
4882
4894
  };