testomatio-editor-blocks 0.4.18 → 0.4.19

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.
@@ -91,6 +91,31 @@ export const stepBlock = createReactBlockSpec({
91
91
  }
92
92
  return count;
93
93
  }, [block.id, documentVersion, editor.document]);
94
+ // Check if there is a preceding "Steps" heading
95
+ const hasStepsHeading = useMemo(() => {
96
+ const allBlocks = editor.document;
97
+ const blockIndex = allBlocks.findIndex((b) => b.id === block.id);
98
+ if (blockIndex < 0)
99
+ return false;
100
+ for (let i = blockIndex - 1; i >= 0; i--) {
101
+ const b = allBlocks[i];
102
+ if (b.type === "testStep" || b.type === "snippet") {
103
+ continue;
104
+ }
105
+ if (b.type === "heading") {
106
+ const text = (Array.isArray(b.content) ? b.content : [])
107
+ .filter((n) => n.type === "text")
108
+ .map((n) => { var _a; return (_a = n.text) !== null && _a !== void 0 ? _a : ""; })
109
+ .join("")
110
+ .trim()
111
+ .toLowerCase()
112
+ .replace(/[:\-–—]$/, "");
113
+ return text === "steps";
114
+ }
115
+ return false;
116
+ }
117
+ return false;
118
+ }, [block.id, documentVersion, editor.document]);
94
119
  useEditorChange(() => {
95
120
  setDocumentVersion((version) => version + 1);
96
121
  }, editor);
@@ -229,6 +254,10 @@ export const stepBlock = createReactBlockSpec({
229
254
  }, [expectedHasContent, isExpectedVisible]);
230
255
  const canToggleData = !dataHasContent;
231
256
  const canToggleExpected = !expectedHasContent;
257
+ // Render as plain text when not under a "Steps" heading
258
+ if (!hasStepsHeading) {
259
+ return (_jsxs("div", { className: "bn-teststep-plain", "data-block-id": block.id, children: [_jsx("span", { children: stepTitle || "(empty step)" }), stepData ? _jsx("span", { className: "bn-teststep-plain__data", children: stepData }) : null, expectedResult ? _jsx("span", { className: "bn-teststep-plain__expected", children: expectedResult }) : null] }));
260
+ }
232
261
  if (viewMode === "horizontal") {
233
262
  return (_jsx(StepHorizontalView, { blockId: block.id, stepNumber: stepNumber, stepValue: combinedStepValue, expectedResult: expectedResult, onStepChange: handleCombinedStepChange, onExpectedChange: handleExpectedChange, onInsertNextStep: handleInsertNextStep, onFieldFocus: handleFieldFocus, viewToggle: _jsx("button", { type: "button", className: "bn-teststep__view-toggle bn-teststep__view-toggle--horizontal", "data-tooltip": "Switch step view", "aria-label": "Switch step view", onClick: handleToggleView, children: _jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [_jsx("mask", { id: "mask-toggle", style: { maskType: "alpha" }, maskUnits: "userSpaceOnUse", x: "0", y: "0", width: "16", height: "16", children: _jsx("rect", { width: "16", height: "16", fill: "#D9D9D9" }) }), _jsx("g", { mask: "url(#mask-toggle)", children: _jsx("path", { d: "M12.6667 2C13.0333 2 13.3472 2.13056 13.6083 2.39167C13.8694 2.65278 14 2.96667 14 3.33333L14 12.6667C14 13.0333 13.8694 13.3472 13.6083 13.6083C13.3472 13.8694 13.0333 14 12.6667 14L10 14C9.63333 14 9.31944 13.8694 9.05833 13.6083C8.79722 13.3472 8.66667 13.0333 8.66667 12.6667L8.66667 3.33333C8.66667 2.96667 8.79722 2.65278 9.05833 2.39167C9.31945 2.13055 9.63333 2 10 2L12.6667 2ZM6 2C6.36667 2 6.68056 2.13055 6.94167 2.39167C7.20278 2.65278 7.33333 2.96667 7.33333 3.33333L7.33333 12.6667C7.33333 13.0333 7.20278 13.3472 6.94167 13.6083C6.68055 13.8694 6.36667 14 6 14L3.33333 14C2.96667 14 2.65278 13.8694 2.39167 13.6083C2.13056 13.3472 2 13.0333 2 12.6667L2 3.33333C2 2.96667 2.13056 2.65278 2.39167 2.39167C2.65278 2.13055 2.96667 2 3.33333 2L6 2ZM3.33333 12.6667L6 12.6667L6 3.33333L3.33333 3.33333L3.33333 12.6667Z", fill: "currentColor" }) })] }) }) }));
234
263
  }
@@ -354,6 +354,21 @@ html.dark .bn-step-image-preview__content {
354
354
  background: var(--status-blocked-bg);
355
355
  }
356
356
 
357
+ .bn-teststep-plain {
358
+ padding: 4px 0;
359
+ font-family: "Inter", system-ui, -apple-system, sans-serif;
360
+ font-size: 14px;
361
+ line-height: 20px;
362
+ color: #262626;
363
+ }
364
+
365
+ .bn-teststep-plain__data,
366
+ .bn-teststep-plain__expected {
367
+ display: block;
368
+ color: #737373;
369
+ font-size: 13px;
370
+ }
371
+
357
372
  .bn-teststep,
358
373
  .bn-teststep button,
359
374
  .bn-teststep input,
@@ -490,19 +505,15 @@ html.dark .bn-step-image-preview__content {
490
505
  }
491
506
 
492
507
  .bn-teststep__view-toggle[data-tooltip]::after {
493
- bottom: auto;
494
- left: auto;
495
- right: calc(100% + 6px);
496
- top: 50%;
497
- transform: translateY(-50%);
508
+ top: calc(100% + 6px);
509
+ left: 50%;
510
+ transform: translateX(-50%);
498
511
  }
499
512
 
500
513
  .bn-teststep__view-toggle--horizontal[data-tooltip]::after {
501
- bottom: auto;
502
- left: auto;
503
- right: calc(100% + 6px);
504
- top: 50%;
505
- transform: translateY(-50%) rotate(-90deg);
514
+ top: calc(100% + 6px);
515
+ left: 50%;
516
+ transform: translateX(-50%);
506
517
  }
507
518
 
508
519
  .bn-teststep__horizontal-fields {
@@ -946,7 +957,7 @@ html.dark .bn-step-image-preview__content {
946
957
  [data-tooltip]::after {
947
958
  content: attr(data-tooltip);
948
959
  position: absolute;
949
- bottom: calc(100% + 6px);
960
+ top: calc(100% + 6px);
950
961
  left: 50%;
951
962
  transform: translateX(-50%);
952
963
  background: #0a0a0a;
@@ -986,7 +997,7 @@ html.dark .bn-step-image-preview__content {
986
997
  font-weight: 400;
987
998
  line-height: 20px;
988
999
  color: #262626;
989
- overflow: hidden;
1000
+ overflow: visible;
990
1001
  }
991
1002
 
992
1003
  .bn-step-editor--multiline {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testomatio-editor-blocks",
3
- "version": "0.4.18",
3
+ "version": "0.4.19",
4
4
  "description": "Custom BlockNote schema, markdown conversion helpers, and UI for Testomatio-style test cases and steps.",
5
5
  "type": "module",
6
6
  "main": "./package/index.js",
@@ -100,6 +100,32 @@ export const stepBlock = createReactBlockSpec(
100
100
  return count;
101
101
  }, [block.id, documentVersion, editor.document]);
102
102
 
103
+ // Check if there is a preceding "Steps" heading
104
+ const hasStepsHeading = useMemo(() => {
105
+ const allBlocks = editor.document;
106
+ const blockIndex = allBlocks.findIndex((b) => b.id === block.id);
107
+ if (blockIndex < 0) return false;
108
+
109
+ for (let i = blockIndex - 1; i >= 0; i--) {
110
+ const b = allBlocks[i];
111
+ if (b.type === "testStep" || b.type === "snippet") {
112
+ continue;
113
+ }
114
+ if (b.type === "heading") {
115
+ const text = (Array.isArray(b.content) ? b.content : [])
116
+ .filter((n: any) => n.type === "text")
117
+ .map((n: any) => n.text ?? "")
118
+ .join("")
119
+ .trim()
120
+ .toLowerCase()
121
+ .replace(/[:\-–—]$/, "");
122
+ return text === "steps";
123
+ }
124
+ return false;
125
+ }
126
+ return false;
127
+ }, [block.id, documentVersion, editor.document]);
128
+
103
129
  useEditorChange(() => {
104
130
  setDocumentVersion((version) => version + 1);
105
131
  }, editor);
@@ -273,6 +299,17 @@ export const stepBlock = createReactBlockSpec(
273
299
  const canToggleData = !dataHasContent;
274
300
  const canToggleExpected = !expectedHasContent;
275
301
 
302
+ // Render as plain text when not under a "Steps" heading
303
+ if (!hasStepsHeading) {
304
+ return (
305
+ <div className="bn-teststep-plain" data-block-id={block.id}>
306
+ <span>{stepTitle || "(empty step)"}</span>
307
+ {stepData ? <span className="bn-teststep-plain__data">{stepData}</span> : null}
308
+ {expectedResult ? <span className="bn-teststep-plain__expected">{expectedResult}</span> : null}
309
+ </div>
310
+ );
311
+ }
312
+
276
313
  if (viewMode === "horizontal") {
277
314
  return (
278
315
  <StepHorizontalView
@@ -354,6 +354,21 @@ html.dark .bn-step-image-preview__content {
354
354
  background: var(--status-blocked-bg);
355
355
  }
356
356
 
357
+ .bn-teststep-plain {
358
+ padding: 4px 0;
359
+ font-family: "Inter", system-ui, -apple-system, sans-serif;
360
+ font-size: 14px;
361
+ line-height: 20px;
362
+ color: #262626;
363
+ }
364
+
365
+ .bn-teststep-plain__data,
366
+ .bn-teststep-plain__expected {
367
+ display: block;
368
+ color: #737373;
369
+ font-size: 13px;
370
+ }
371
+
357
372
  .bn-teststep,
358
373
  .bn-teststep button,
359
374
  .bn-teststep input,
@@ -490,19 +505,15 @@ html.dark .bn-step-image-preview__content {
490
505
  }
491
506
 
492
507
  .bn-teststep__view-toggle[data-tooltip]::after {
493
- bottom: auto;
494
- left: auto;
495
- right: calc(100% + 6px);
496
- top: 50%;
497
- transform: translateY(-50%);
508
+ top: calc(100% + 6px);
509
+ left: 50%;
510
+ transform: translateX(-50%);
498
511
  }
499
512
 
500
513
  .bn-teststep__view-toggle--horizontal[data-tooltip]::after {
501
- bottom: auto;
502
- left: auto;
503
- right: calc(100% + 6px);
504
- top: 50%;
505
- transform: translateY(-50%) rotate(-90deg);
514
+ top: calc(100% + 6px);
515
+ left: 50%;
516
+ transform: translateX(-50%);
506
517
  }
507
518
 
508
519
  .bn-teststep__horizontal-fields {
@@ -946,7 +957,7 @@ html.dark .bn-step-image-preview__content {
946
957
  [data-tooltip]::after {
947
958
  content: attr(data-tooltip);
948
959
  position: absolute;
949
- bottom: calc(100% + 6px);
960
+ top: calc(100% + 6px);
950
961
  left: 50%;
951
962
  transform: translateX(-50%);
952
963
  background: #0a0a0a;
@@ -986,7 +997,7 @@ html.dark .bn-step-image-preview__content {
986
997
  font-weight: 400;
987
998
  line-height: 20px;
988
999
  color: #262626;
989
- overflow: hidden;
1000
+ overflow: visible;
990
1001
  }
991
1002
 
992
1003
  .bn-step-editor--multiline {