@portabletext/editor 2.1.4 → 2.1.6
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.
- package/lib/_chunks-dts/behavior.types.action.d.ts +9 -9
- package/lib/index.cjs +7 -9
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +6 -9
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +6 -8
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.ts +3 -3
- package/lib/plugins/index.js +5 -8
- package/lib/plugins/index.js.map +1 -1
- package/package.json +4 -5
- package/src/editor-event-listener.tsx +2 -4
- package/src/internal-utils/build-index-maps.test.ts +41 -24
- package/src/internal-utils/build-index-maps.ts +4 -1
- package/src/plugins/plugin.event-listener.tsx +2 -4
package/lib/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { c } from "react-compiler-runtime";
|
|
2
2
|
import React, { useEffect, createContext, useContext, useState, useRef, Component, useMemo, startTransition, useCallback, forwardRef, useImperativeHandle } from "react";
|
|
3
|
-
import { useEffectEvent } from "use-effect-event";
|
|
4
3
|
import { useEditor, EditorContext } from "./_chunks-es/use-editor.js";
|
|
5
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
6
5
|
import { useSelector, useActorRef } from "@xstate/react";
|
|
@@ -36,16 +35,14 @@ import { defineType, defineField } from "@sanity/types";
|
|
|
36
35
|
import startCase from "lodash.startcase";
|
|
37
36
|
import isPlainObject from "lodash/isPlainObject.js";
|
|
38
37
|
function EditorEventListener(props) {
|
|
39
|
-
const $ = c(
|
|
40
|
-
let t0;
|
|
41
|
-
$[0] !== editor || $[1] !== on ? (t0 = () => {
|
|
42
|
-
const subscription = editor.on("*", on);
|
|
38
|
+
const $ = c(4), editor = useEditor();
|
|
39
|
+
let t0, t1;
|
|
40
|
+
return $[0] !== editor || $[1] !== props.on ? (t0 = () => {
|
|
41
|
+
const subscription = editor.on("*", props.on);
|
|
43
42
|
return () => {
|
|
44
43
|
subscription.unsubscribe();
|
|
45
44
|
};
|
|
46
|
-
}, $[0] = editor, $[1] = on, $[2] = t0) : t0 = $[2];
|
|
47
|
-
let t1;
|
|
48
|
-
return $[3] !== editor ? (t1 = [editor], $[3] = editor, $[4] = t1) : t1 = $[4], useEffect(t0, t1), null;
|
|
45
|
+
}, t1 = [editor, props.on], $[0] = editor, $[1] = props.on, $[2] = t0, $[3] = t1) : (t0 = $[2], t1 = $[3]), useEffect(t0, t1), null;
|
|
49
46
|
}
|
|
50
47
|
const rootName = "sanity-pte:";
|
|
51
48
|
debug$f(rootName);
|
|
@@ -1344,7 +1341,7 @@ function buildIndexMaps(context, {
|
|
|
1344
1341
|
}, levelIndexMap.set(block.level, 1), listIndexMap.set(block._key, 1);
|
|
1345
1342
|
continue;
|
|
1346
1343
|
}
|
|
1347
|
-
if (previousListItem.listItem !== block.listItem) {
|
|
1344
|
+
if (previousListItem.listItem !== block.listItem && previousListItem.level === block.level) {
|
|
1348
1345
|
levelIndexMap.clear(), previousListItem = {
|
|
1349
1346
|
listItem: block.listItem,
|
|
1350
1347
|
level: block.level
|