@portabletext/editor 1.30.2 → 1.30.4

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.
@@ -1655,7 +1655,7 @@ function findOperationTargetBlock(editor, operation) {
1655
1655
  let block;
1656
1656
  return operation.type === "set_selection" && editor.selection ? block = editor.children[editor.selection.focus.path[0]] : "path" in operation && (block = editor.children[operation.path[0]]), block;
1657
1657
  }
1658
- const syncValueCallback = ({
1658
+ const debug$d = debugWithName("sync machine"), syncValueCallback = ({
1659
1659
  sendBack,
1660
1660
  input
1661
1661
  }) => {
@@ -1705,7 +1705,15 @@ const syncValueCallback = ({
1705
1705
  }) => context.initialValueSynced,
1706
1706
  "is busy": ({
1707
1707
  context
1708
- }) => !context.readOnly && (context.isProcessingLocalChanges || (isChangingRemotely(context.slateEditor) ?? !1)),
1708
+ }) => {
1709
+ const editable = !context.readOnly, isProcessingLocalChanges = context.isProcessingLocalChanges, isChanging = isChangingRemotely(context.slateEditor) ?? !1, isBusy = editable && (isProcessingLocalChanges || isChanging);
1710
+ return debug$d("isBusy", {
1711
+ isBusy,
1712
+ editable,
1713
+ isProcessingLocalChanges,
1714
+ isChanging
1715
+ }), isBusy;
1716
+ },
1709
1717
  "value changed while syncing": ({
1710
1718
  context,
1711
1719
  event
@@ -1752,13 +1760,24 @@ const syncValueCallback = ({
1752
1760
  initial: "syncing initial value",
1753
1761
  states: {
1754
1762
  "syncing initial value": {
1763
+ entry: [() => {
1764
+ debug$d("entry: syncing initial value");
1765
+ }],
1766
+ exit: [() => {
1767
+ debug$d("exit: syncing initial value");
1768
+ }],
1755
1769
  always: {
1756
1770
  guard: "initial value synced",
1757
1771
  target: "done syncing initial value"
1758
1772
  }
1759
1773
  },
1760
1774
  "done syncing initial value": {
1761
- entry: ["emit done syncing initial value"],
1775
+ entry: ["emit done syncing initial value", () => {
1776
+ debug$d("entry: done syncing initial value");
1777
+ }],
1778
+ exit: [() => {
1779
+ debug$d("exit: done syncing initial value");
1780
+ }],
1762
1781
  type: "final"
1763
1782
  }
1764
1783
  }
@@ -1767,6 +1786,12 @@ const syncValueCallback = ({
1767
1786
  initial: "idle",
1768
1787
  states: {
1769
1788
  idle: {
1789
+ entry: [() => {
1790
+ debug$d("entry: syncing->idle");
1791
+ }],
1792
+ exit: [() => {
1793
+ debug$d("exit: syncing->idle");
1794
+ }],
1770
1795
  on: {
1771
1796
  "update value": [{
1772
1797
  guard: "is busy",
@@ -1779,10 +1804,20 @@ const syncValueCallback = ({
1779
1804
  }
1780
1805
  },
1781
1806
  busy: {
1807
+ entry: [() => {
1808
+ debug$d("entry: syncing->busy");
1809
+ }],
1810
+ exit: [() => {
1811
+ debug$d("exit: syncing->busy");
1812
+ }],
1782
1813
  after: {
1783
1814
  1e3: [{
1784
1815
  guard: "is busy",
1785
- reenter: !0
1816
+ target: ".",
1817
+ reenter: !0,
1818
+ actions: [() => {
1819
+ debug$d("reenter: syncing->busy");
1820
+ }]
1786
1821
  }, {
1787
1822
  target: "syncing"
1788
1823
  }]
@@ -1794,6 +1829,12 @@ const syncValueCallback = ({
1794
1829
  }
1795
1830
  },
1796
1831
  syncing: {
1832
+ entry: [() => {
1833
+ debug$d("entry: syncing->syncing");
1834
+ }],
1835
+ exit: [() => {
1836
+ debug$d("exit: syncing->syncing");
1837
+ }],
1797
1838
  always: {
1798
1839
  guard: "pending value equals previous value",
1799
1840
  target: "idle",
@@ -1848,7 +1889,7 @@ const syncValueCallback = ({
1848
1889
  }
1849
1890
  }
1850
1891
  }
1851
- }), debug$d = debugWithName("hook:useSyncValue");
1892
+ });
1852
1893
  async function updateValue({
1853
1894
  context,
1854
1895
  sendBack,
@@ -6620,7 +6661,7 @@ class PortableTextEditor extends React.Component {
6620
6661
  * const selectedSlice = useEditorSelector(editor, selectors.getSelectedSlice)
6621
6662
  * ```
6622
6663
  */
6623
- static getFragment = (editor) => (debug("Host getting fragment"), editor.editable?.getFragment());
6664
+ static getFragment = (editor) => editor.editable?.getFragment();
6624
6665
  static undo = (editor) => {
6625
6666
  debug("Host undoing"), editor.editable?.undo();
6626
6667
  };