testomatio-editor-blocks 0.4.16 → 0.4.18
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.
|
@@ -77,9 +77,19 @@ export const stepBlock = createReactBlockSpec({
|
|
|
77
77
|
// Calculate step number based on position in document
|
|
78
78
|
const stepNumber = useMemo(() => {
|
|
79
79
|
const allBlocks = editor.document;
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
const blockIndex = allBlocks.findIndex((b) => b.id === block.id);
|
|
81
|
+
if (blockIndex < 0)
|
|
82
|
+
return 1;
|
|
83
|
+
let count = 1;
|
|
84
|
+
for (let i = blockIndex - 1; i >= 0; i--) {
|
|
85
|
+
if (allBlocks[i].type === "testStep") {
|
|
86
|
+
count++;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return count;
|
|
83
93
|
}, [block.id, documentVersion, editor.document]);
|
|
84
94
|
useEditorChange(() => {
|
|
85
95
|
setDocumentVersion((version) => version + 1);
|
package/package.json
CHANGED
|
@@ -86,9 +86,18 @@ export const stepBlock = createReactBlockSpec(
|
|
|
86
86
|
// Calculate step number based on position in document
|
|
87
87
|
const stepNumber = useMemo(() => {
|
|
88
88
|
const allBlocks = editor.document;
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
const blockIndex = allBlocks.findIndex((b) => b.id === block.id);
|
|
90
|
+
if (blockIndex < 0) return 1;
|
|
91
|
+
|
|
92
|
+
let count = 1;
|
|
93
|
+
for (let i = blockIndex - 1; i >= 0; i--) {
|
|
94
|
+
if (allBlocks[i].type === "testStep") {
|
|
95
|
+
count++;
|
|
96
|
+
} else {
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return count;
|
|
92
101
|
}, [block.id, documentVersion, editor.document]);
|
|
93
102
|
|
|
94
103
|
useEditorChange(() => {
|