slate-react 0.131.0-20261008213913 → 0.131.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.
@@ -2596,6 +2596,18 @@
2596
2596
  *
2597
2597
  * See https://docs.slatejs.org/concepts/11-typescript to learn how.
2598
2598
  */
2599
+ const wrapInInlineAncestors = (contents, start, editorElement) => {
2600
+ let wrapped = contents;
2601
+ for (let ancestor = isDOMElement(start) ? start : start.parentElement; ancestor && ancestor !== editorElement; ancestor = ancestor.parentElement) {
2602
+ if (ancestor.getAttribute('data-slate-inline') === 'true' && !ancestor.hasAttribute('data-slate-void')) {
2603
+ const shell = ancestor.cloneNode(false);
2604
+ shell.appendChild(wrapped);
2605
+ wrapped = ancestor.ownerDocument.createDocumentFragment();
2606
+ wrapped.appendChild(shell);
2607
+ }
2608
+ }
2609
+ return wrapped;
2610
+ };
2599
2611
  const withDOM = (editor, clipboardFormatKey = 'x-slate-fragment') => {
2600
2612
  const e = editor;
2601
2613
  const {
@@ -2827,6 +2839,9 @@
2827
2839
  const encoded = window.btoa(encodeURIComponent(string));
2828
2840
  attach.setAttribute('data-slate-fragment', encoded);
2829
2841
  data.setData(`application/${clipboardFormatKey}`, encoded);
2842
+ if (!startVoid && !endVoid) {
2843
+ contents = wrapInInlineAncestors(contents, domRange.commonAncestorContainer, DOMEditor.toDOMNode(e, e));
2844
+ }
2830
2845
  // Add the content to a <div> so that we can get its inner HTML.
2831
2846
  const div = contents.ownerDocument.createElement('div');
2832
2847
  div.appendChild(contents);