@contentful/field-editor-rich-text 2.0.0-next.14 → 2.0.0-next.15

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.
@@ -9,7 +9,7 @@ import noop from 'lodash-es/noop';
9
9
  import { createDeserializeDocxPlugin } from '@udecode/plate-serializer-docx';
10
10
  import { createSoftBreakPlugin as createSoftBreakPlugin$1, createExitBreakPlugin as createExitBreakPlugin$1 } from '@udecode/plate-break';
11
11
  import isHotkey from 'is-hotkey';
12
- import { Text, Element, Editor, Transforms, Range, Path, Node, Point } from 'slate';
12
+ import { Text, Element, Editor, Transforms, Range, Node, Path, Point } from 'slate';
13
13
  import { ReactEditor, useSelected, useReadOnly, useFocused } from 'slate-react';
14
14
  import constate from 'constate';
15
15
  import { AssetCard, Menu, Text as Text$1, Notification, EntryCard, MenuItem, Button, Flex, Icon, InlineEntryCard, Tooltip, ModalContent, Form, FormControl, TextInput, Select, FormLabel, TextLink, ModalControls, IconButton } from '@contentful/f36-components';
@@ -2793,10 +2793,6 @@ function withHrEvents(editor) {
2793
2793
  pathToSelectedHr = _getNodeEntryFromSele[1];
2794
2794
 
2795
2795
  if (pathToSelectedHr) {
2796
- if (shouldUnwrapBlockquote(editor, BLOCKS.HR)) {
2797
- unwrapFromRoot(editor);
2798
- }
2799
-
2800
2796
  var isBackspace = event.key === 'Backspace';
2801
2797
  var isDelete = event.key === 'Delete';
2802
2798
 
@@ -2814,11 +2810,6 @@ function ToolbarHrButton(props) {
2814
2810
 
2815
2811
  function handleOnClick() {
2816
2812
  if (!(editor != null && editor.selection)) return;
2817
-
2818
- if (shouldUnwrapBlockquote(editor, BLOCKS.HR)) {
2819
- unwrapFromRoot(editor);
2820
- }
2821
-
2822
2813
  var hr = {
2823
2814
  type: BLOCKS.HR,
2824
2815
  data: {},
@@ -4694,11 +4685,54 @@ var sanitizeHTML = function sanitizeHTML(html) {
4694
4685
  return doc.body.innerHTML.replace(/>\s+</g, '><');
4695
4686
  };
4696
4687
 
4688
+ /**
4689
+ * Get x-slate-fragment attribute from data-slate-fragment
4690
+ */
4691
+
4692
+ var catchSlateFragment = /data-slate-fragment="(.+?)"/m;
4693
+ var getSlateFragmentAttribute = function getSlateFragmentAttribute(dataTransfer) {
4694
+ var htmlData = dataTransfer.getData('text/html');
4695
+
4696
+ var _ref = htmlData.match(catchSlateFragment) || [],
4697
+ fragment = _ref[1];
4698
+
4699
+ return fragment;
4700
+ };
4701
+ /**
4702
+ * Get the x-slate-fragment attribute that exist in text/html data
4703
+ * and append it to the DataTransfer object
4704
+ */
4705
+
4706
+ var ensureXSlateFragment = function ensureXSlateFragment(dataTransfer) {
4707
+ if (!dataTransfer.getData('application/x-slate-fragment')) {
4708
+ var fragment = getSlateFragmentAttribute(dataTransfer);
4709
+
4710
+ if (fragment) {
4711
+ var clipboardData = new DataTransfer();
4712
+ dataTransfer.types.forEach(function (type) {
4713
+ clipboardData.setData(type, dataTransfer.getData(type));
4714
+ });
4715
+ clipboardData.setData('application/x-slate-fragment', fragment);
4716
+ return clipboardData;
4717
+ }
4718
+ }
4719
+
4720
+ return dataTransfer;
4721
+ };
4697
4722
  var createPasteHTMLPlugin = function createPasteHTMLPlugin() {
4698
4723
  var _pluginsByKey;
4699
4724
 
4700
4725
  return {
4701
4726
  key: 'PasteHTMLPlugin',
4727
+ withOverrides: function withOverrides(editor) {
4728
+ var insertData = editor.insertData;
4729
+
4730
+ editor.insertData = function (data) {
4731
+ return insertData(ensureXSlateFragment(data));
4732
+ };
4733
+
4734
+ return editor;
4735
+ },
4702
4736
  inject: {
4703
4737
  pluginsByKey: (_pluginsByKey = {}, _pluginsByKey[KEY_DESERIALIZE_HTML] = {
4704
4738
  editor: {