testomatio-editor-blocks 0.4.39 → 0.4.40
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/package/editor/customMarkdownConverter.js +1 -1
- package/package/editor/snippetAutocomplete.js +6 -6
- package/package/editor/stepAutocomplete.js +6 -6
- package/package.json +1 -1
- package/src/editor/customMarkdownConverter.test.ts +18 -0
- package/src/editor/customMarkdownConverter.ts +1 -1
- package/src/editor/snippetAutocomplete.ts +5 -6
- package/src/editor/stepAutocomplete.tsx +5 -6
|
@@ -652,7 +652,7 @@ function parseList(lines, startIndex, listType, indentLevel, allowEmptySteps = f
|
|
|
652
652
|
// Check if this line should be parsed as nested content
|
|
653
653
|
// Only go deeper if indent is at least 2 more than the next level's expected indent
|
|
654
654
|
const nextLevelExpectedIndent = (indentLevel + 1) * 2;
|
|
655
|
-
if (indent >= nextLevelExpectedIndent) {
|
|
655
|
+
if (indent >= nextLevelExpectedIndent && items.length > 0) {
|
|
656
656
|
const lastItem = items.at(-1);
|
|
657
657
|
if (!lastItem) {
|
|
658
658
|
break;
|
|
@@ -13,14 +13,14 @@ export function useSnippetAutocomplete() {
|
|
|
13
13
|
return cachedSuggestions;
|
|
14
14
|
if (!globalFetcher)
|
|
15
15
|
return [];
|
|
16
|
+
if (inflightPromise)
|
|
17
|
+
return [];
|
|
16
18
|
const result = globalFetcher();
|
|
17
19
|
if (result && typeof result.then === "function") {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.catch((error) => { inflightPromise = null; console.error("Failed to fetch snippet suggestions", error); return []; });
|
|
23
|
-
}
|
|
20
|
+
inflightPromise = result
|
|
21
|
+
.then((r) => normalizeSnippetSuggestions(r))
|
|
22
|
+
.then((items) => { cachedSuggestions = items; inflightPromise = null; return items; })
|
|
23
|
+
.catch((error) => { inflightPromise = null; console.error("Failed to fetch snippet suggestions", error); return []; });
|
|
24
24
|
return [];
|
|
25
25
|
}
|
|
26
26
|
const normalized = normalizeSnippetSuggestions(result);
|
|
@@ -13,14 +13,14 @@ export function useStepAutocomplete() {
|
|
|
13
13
|
return cachedSuggestions;
|
|
14
14
|
if (!globalFetcher)
|
|
15
15
|
return [];
|
|
16
|
+
if (inflightPromise)
|
|
17
|
+
return [];
|
|
16
18
|
const result = globalFetcher();
|
|
17
19
|
if (result && typeof result.then === "function") {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.catch((error) => { inflightPromise = null; console.error("Failed to fetch step suggestions", error); return []; });
|
|
23
|
-
}
|
|
20
|
+
inflightPromise = result
|
|
21
|
+
.then((r) => normalizeStepSuggestions(r))
|
|
22
|
+
.then((items) => { cachedSuggestions = items; inflightPromise = null; return items; })
|
|
23
|
+
.catch((error) => { inflightPromise = null; console.error("Failed to fetch step suggestions", error); return []; });
|
|
24
24
|
return [];
|
|
25
25
|
}
|
|
26
26
|
const normalized = normalizeStepSuggestions(result);
|
package/package.json
CHANGED
|
@@ -1008,6 +1008,24 @@ describe("markdownToBlocks", () => {
|
|
|
1008
1008
|
expect(nestedChildren.some((child) => child.type === "bulletListItem")).toBe(true);
|
|
1009
1009
|
});
|
|
1010
1010
|
|
|
1011
|
+
it("does not freeze on indented list items without a parent", () => {
|
|
1012
|
+
const markdown = [
|
|
1013
|
+
"### Requirements",
|
|
1014
|
+
"",
|
|
1015
|
+
" * The system should log in the user {{username}} with password ${password} successfully.",
|
|
1016
|
+
"",
|
|
1017
|
+
" ### Steps",
|
|
1018
|
+
"",
|
|
1019
|
+
" * Open login page",
|
|
1020
|
+
" *Expected*: The main page is opened",
|
|
1021
|
+
].join("\n");
|
|
1022
|
+
|
|
1023
|
+
const blocks = markdownToBlocks(markdown);
|
|
1024
|
+
expect(blocks.length).toBeGreaterThan(0);
|
|
1025
|
+
const bullets = blocks.filter((b) => b.type === "bulletListItem");
|
|
1026
|
+
expect(bullets.length).toBeGreaterThanOrEqual(1);
|
|
1027
|
+
});
|
|
1028
|
+
|
|
1011
1029
|
it("parses expected result prefixes with emphasis", () => {
|
|
1012
1030
|
const markdown = [
|
|
1013
1031
|
"* Open the form.",
|
|
@@ -796,7 +796,7 @@ function parseList(
|
|
|
796
796
|
// Check if this line should be parsed as nested content
|
|
797
797
|
// Only go deeper if indent is at least 2 more than the next level's expected indent
|
|
798
798
|
const nextLevelExpectedIndent = (indentLevel + 1) * 2;
|
|
799
|
-
if (indent >= nextLevelExpectedIndent) {
|
|
799
|
+
if (indent >= nextLevelExpectedIndent && items.length > 0) {
|
|
800
800
|
const lastItem = items.at(-1);
|
|
801
801
|
if (!lastItem) {
|
|
802
802
|
break;
|
|
@@ -45,14 +45,13 @@ export function useSnippetAutocomplete(): SnippetSuggestion[] {
|
|
|
45
45
|
const [suggestions, setSuggestions] = useState<SnippetSuggestion[]>(() => {
|
|
46
46
|
if (cachedSuggestions.length > 0) return cachedSuggestions;
|
|
47
47
|
if (!globalFetcher) return [];
|
|
48
|
+
if (inflightPromise) return [];
|
|
48
49
|
const result = globalFetcher();
|
|
49
50
|
if (result && typeof (result as Promise<unknown>).then === "function") {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.catch((error) => { inflightPromise = null; console.error("Failed to fetch snippet suggestions", error); return [] as SnippetSuggestion[]; });
|
|
55
|
-
}
|
|
51
|
+
inflightPromise = (result as Promise<SnippetInput>)
|
|
52
|
+
.then((r) => normalizeSnippetSuggestions(r))
|
|
53
|
+
.then((items) => { cachedSuggestions = items; inflightPromise = null; return items; })
|
|
54
|
+
.catch((error) => { inflightPromise = null; console.error("Failed to fetch snippet suggestions", error); return [] as SnippetSuggestion[]; });
|
|
56
55
|
return [];
|
|
57
56
|
}
|
|
58
57
|
const normalized = normalizeSnippetSuggestions(result as SnippetInput);
|
|
@@ -51,14 +51,13 @@ export function useStepAutocomplete(): StepSuggestion[] {
|
|
|
51
51
|
const [suggestions, setSuggestions] = useState<StepSuggestion[]>(() => {
|
|
52
52
|
if (cachedSuggestions.length > 0) return cachedSuggestions;
|
|
53
53
|
if (!globalFetcher) return [];
|
|
54
|
+
if (inflightPromise) return [];
|
|
54
55
|
const result = globalFetcher();
|
|
55
56
|
if (result && typeof (result as Promise<unknown>).then === "function") {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
.catch((error) => { inflightPromise = null; console.error("Failed to fetch step suggestions", error); return [] as StepSuggestion[]; });
|
|
61
|
-
}
|
|
57
|
+
inflightPromise = (result as Promise<StepInput>)
|
|
58
|
+
.then((r) => normalizeStepSuggestions(r))
|
|
59
|
+
.then((items) => { cachedSuggestions = items; inflightPromise = null; return items; })
|
|
60
|
+
.catch((error) => { inflightPromise = null; console.error("Failed to fetch step suggestions", error); return [] as StepSuggestion[]; });
|
|
62
61
|
return [];
|
|
63
62
|
}
|
|
64
63
|
const normalized = normalizeStepSuggestions(result as StepInput);
|