@portabletext/editor 1.30.2 → 1.30.3

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.
@@ -1678,7 +1678,7 @@ function findOperationTargetBlock(editor, operation) {
1678
1678
  let block;
1679
1679
  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;
1680
1680
  }
1681
- const syncValueCallback = ({
1681
+ const debug$d = debugWithName("sync machine"), syncValueCallback = ({
1682
1682
  sendBack,
1683
1683
  input
1684
1684
  }) => {
@@ -1728,7 +1728,15 @@ const syncValueCallback = ({
1728
1728
  }) => context.initialValueSynced,
1729
1729
  "is busy": ({
1730
1730
  context
1731
- }) => !context.readOnly && (context.isProcessingLocalChanges || (isChangingRemotely(context.slateEditor) ?? !1)),
1731
+ }) => {
1732
+ const editable = !context.readOnly, isProcessingLocalChanges = context.isProcessingLocalChanges, isChanging = isChangingRemotely(context.slateEditor) ?? !1, isBusy = editable && (isProcessingLocalChanges || isChanging);
1733
+ return debug$d("isBusy", {
1734
+ isBusy,
1735
+ editable,
1736
+ isProcessingLocalChanges,
1737
+ isChanging
1738
+ }), isBusy;
1739
+ },
1732
1740
  "value changed while syncing": ({
1733
1741
  context,
1734
1742
  event
@@ -1775,13 +1783,24 @@ const syncValueCallback = ({
1775
1783
  initial: "syncing initial value",
1776
1784
  states: {
1777
1785
  "syncing initial value": {
1786
+ entry: [() => {
1787
+ debug$d("entry: syncing initial value");
1788
+ }],
1789
+ exit: [() => {
1790
+ debug$d("exit: syncing initial value");
1791
+ }],
1778
1792
  always: {
1779
1793
  guard: "initial value synced",
1780
1794
  target: "done syncing initial value"
1781
1795
  }
1782
1796
  },
1783
1797
  "done syncing initial value": {
1784
- entry: ["emit done syncing initial value"],
1798
+ entry: ["emit done syncing initial value", () => {
1799
+ debug$d("entry: done syncing initial value");
1800
+ }],
1801
+ exit: [() => {
1802
+ debug$d("exit: done syncing initial value");
1803
+ }],
1785
1804
  type: "final"
1786
1805
  }
1787
1806
  }
@@ -1790,6 +1809,12 @@ const syncValueCallback = ({
1790
1809
  initial: "idle",
1791
1810
  states: {
1792
1811
  idle: {
1812
+ entry: [() => {
1813
+ debug$d("entry: syncing->idle");
1814
+ }],
1815
+ exit: [() => {
1816
+ debug$d("exit: syncing->idle");
1817
+ }],
1793
1818
  on: {
1794
1819
  "update value": [{
1795
1820
  guard: "is busy",
@@ -1802,10 +1827,20 @@ const syncValueCallback = ({
1802
1827
  }
1803
1828
  },
1804
1829
  busy: {
1830
+ entry: [() => {
1831
+ debug$d("entry: syncing->busy");
1832
+ }],
1833
+ exit: [() => {
1834
+ debug$d("exit: syncing->busy");
1835
+ }],
1805
1836
  after: {
1806
1837
  1e3: [{
1807
1838
  guard: "is busy",
1808
- reenter: !0
1839
+ target: ".",
1840
+ reenter: !0,
1841
+ actions: [() => {
1842
+ debug$d("reenter: syncing->busy");
1843
+ }]
1809
1844
  }, {
1810
1845
  target: "syncing"
1811
1846
  }]
@@ -1817,6 +1852,12 @@ const syncValueCallback = ({
1817
1852
  }
1818
1853
  },
1819
1854
  syncing: {
1855
+ entry: [() => {
1856
+ debug$d("entry: syncing->syncing");
1857
+ }],
1858
+ exit: [() => {
1859
+ debug$d("exit: syncing->syncing");
1860
+ }],
1820
1861
  always: {
1821
1862
  guard: "pending value equals previous value",
1822
1863
  target: "idle",
@@ -1871,7 +1912,7 @@ const syncValueCallback = ({
1871
1912
  }
1872
1913
  }
1873
1914
  }
1874
- }), debug$d = debugWithName("hook:useSyncValue");
1915
+ });
1875
1916
  async function updateValue({
1876
1917
  context,
1877
1918
  sendBack,
@@ -6643,7 +6684,7 @@ class PortableTextEditor extends Component {
6643
6684
  * const selectedSlice = useEditorSelector(editor, selectors.getSelectedSlice)
6644
6685
  * ```
6645
6686
  */
6646
- static getFragment = (editor) => (debug("Host getting fragment"), editor.editable?.getFragment());
6687
+ static getFragment = (editor) => editor.editable?.getFragment();
6647
6688
  static undo = (editor) => {
6648
6689
  debug("Host undoing"), editor.editable?.undo();
6649
6690
  };