testomatio-editor-blocks 0.4.54 → 0.4.55

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.
@@ -404,7 +404,7 @@ export const stepBlock = createReactBlockSpec({
404
404
  if (!effectiveVertical) {
405
405
  return (_jsx(StepHorizontalView, { ref: containerRef, blockId: block.id, stepNumber: stepNumber, stepValue: combinedStepValue, expectedResult: expectedResult, onStepChange: handleCombinedStepChange, onExpectedChange: handleExpectedChange, onInsertNextStep: handleInsertNextStep, onFieldFocus: handleFieldFocus, viewToggle: viewToggleButton }));
406
406
  }
407
- return (_jsxs("div", { className: "bn-teststep", "data-block-id": block.id, ref: containerRef, children: [_jsxs("div", { className: "bn-teststep__timeline", children: [_jsx("span", { className: "bn-teststep__number", children: stepNumber }), _jsx("div", { className: "bn-teststep__line" })] }), _jsxs("div", { className: "bn-teststep__content", children: [_jsxs("div", { className: "bn-teststep__header", children: [_jsx("span", { className: "bn-teststep__title", children: "Step" }), viewToggleButton] }), _jsx(StepField, { label: "Step", showLabel: false, value: stepTitle, placeholder: STEP_TITLE_PLACEHOLDER, onChange: handleStepTitleChange, autoFocus: stepTitle.length === 0, multiline: true, enableAutocomplete: true, fieldName: "title", suggestionFilter: (suggestion) => suggestion.isSnippet !== true, onFieldFocus: handleFieldFocus, enableImageUpload: false, showFormattingButtons: true, onImageFile: async (file) => {
407
+ return (_jsxs("div", { className: "bn-teststep", "data-block-id": block.id, ref: containerRef, children: [_jsxs("div", { className: "bn-teststep__timeline", children: [_jsx("span", { className: "bn-teststep__number", children: stepNumber }), _jsx("div", { className: "bn-teststep__line" })] }), _jsxs("div", { className: "bn-teststep__content", children: [_jsxs("div", { className: "bn-teststep__header", children: [_jsx("span", { className: "bn-teststep__title", children: "Step" }), viewToggleButton] }), _jsx(StepField, { label: "Step", showLabel: false, value: stepTitle, placeholder: STEP_TITLE_PLACEHOLDER, onChange: handleStepTitleChange, autoFocus: stepTitle.length === 0, multiline: true, disableNewlines: true, enableAutocomplete: true, fieldName: "title", suggestionFilter: (suggestion) => suggestion.isSnippet !== true, onFieldFocus: handleFieldFocus, enableImageUpload: false, showFormattingButtons: true, onImageFile: async (file) => {
408
408
  if (!uploadImage) {
409
409
  return;
410
410
  }
@@ -16,6 +16,7 @@ type StepFieldProps = {
16
16
  autoFocus?: boolean;
17
17
  focusSignal?: number;
18
18
  multiline?: boolean;
19
+ disableNewlines?: boolean;
19
20
  enableAutocomplete?: boolean;
20
21
  fieldName?: string;
21
22
  suggestionFilter?: (suggestion: Suggestion) => boolean;
@@ -53,5 +54,5 @@ export declare function applyInlineExclusion(formatting: FormattingMeta[], links
53
54
  links: LinkMeta[];
54
55
  };
55
56
  export declare function buildFullMarkdown(plainText: string, links: LinkMeta[], formatting: FormattingMeta[]): string;
56
- export declare function StepField({ label, showLabel, labelToggle, labelAction, placeholder, value, onChange, autoFocus, focusSignal, multiline, enableAutocomplete, fieldName, suggestionFilter, suggestionsOverride, onSuggestionSelect, readOnly, showSuggestionsOnFocus, enableImageUpload, onImageFile, rightAction, showFormattingButtons, showImageButton, onFieldFocus, }: StepFieldProps): import("react/jsx-runtime").JSX.Element;
57
+ export declare function StepField({ label, showLabel, labelToggle, labelAction, placeholder, value, onChange, autoFocus, focusSignal, multiline, disableNewlines, enableAutocomplete, fieldName, suggestionFilter, suggestionsOverride, onSuggestionSelect, readOnly, showSuggestionsOnFocus, enableImageUpload, onImageFile, rightAction, showFormattingButtons, showImageButton, onFieldFocus, }: StepFieldProps): import("react/jsx-runtime").JSX.Element;
57
58
  export {};
@@ -532,7 +532,7 @@ function markdownToPlainText(markdown) {
532
532
  return markdown.replace(/!\[[^\]]*]\([^)]+\)/g, "").replace(/\[[^\]]*]\([^)]+\)/g, "").replace(/[*_`~]/g, "").replace(/\s+/g, " ").trim();
533
533
  }
534
534
  }
535
- export function StepField({ label, showLabel = true, labelToggle, labelAction, placeholder, value, onChange, autoFocus, focusSignal, multiline = false, enableAutocomplete = false, fieldName, suggestionFilter, suggestionsOverride, onSuggestionSelect, readOnly = false, showSuggestionsOnFocus = false, enableImageUpload = false, onImageFile, rightAction, showFormattingButtons = false, showImageButton = false, onFieldFocus, }) {
535
+ export function StepField({ label, showLabel = true, labelToggle, labelAction, placeholder, value, onChange, autoFocus, focusSignal, multiline = false, disableNewlines = false, enableAutocomplete = false, fieldName, suggestionFilter, suggestionsOverride, onSuggestionSelect, readOnly = false, showSuggestionsOnFocus = false, enableImageUpload = false, onImageFile, rightAction, showFormattingButtons = false, showImageButton = false, onFieldFocus, }) {
536
536
  var _a, _b;
537
537
  const stepSuggestions = useStepAutocomplete();
538
538
  const suggestions = suggestionsOverride !== null && suggestionsOverride !== void 0 ? suggestionsOverride : stepSuggestions;
@@ -1390,6 +1390,11 @@ export function StepField({ label, showLabel = true, labelToggle, labelAction, p
1390
1390
  setShowAllSuggestions(true);
1391
1391
  return;
1392
1392
  }
1393
+ if (disableNewlines && (event.key === "Enter" || event.code === "Enter")) {
1394
+ event.preventDefault();
1395
+ event.stopImmediatePropagation();
1396
+ return;
1397
+ }
1393
1398
  if (event.key === "Tab") {
1394
1399
  const moved = focusAdjacentField(event.shiftKey ? -1 : 1);
1395
1400
  if (moved) {
@@ -1398,7 +1403,7 @@ export function StepField({ label, showLabel = true, labelToggle, labelAction, p
1398
1403
  }
1399
1404
  }
1400
1405
  };
1401
- }, [activeSuggestionIndex, applySuggestion, enableAutocomplete, filteredSuggestions, focusAdjacentField, handleToolbarAction, readOnly, shouldShowAutocomplete]);
1406
+ }, [activeSuggestionIndex, applySuggestion, disableNewlines, enableAutocomplete, filteredSuggestions, focusAdjacentField, handleToolbarAction, readOnly, shouldShowAutocomplete]);
1402
1407
  useEffect(() => {
1403
1408
  if (!textareaNode) {
1404
1409
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testomatio-editor-blocks",
3
- "version": "0.4.54",
3
+ "version": "0.4.55",
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",
package/src/App.tsx CHANGED
@@ -384,7 +384,13 @@ function App() {
384
384
  schema: customSchema,
385
385
  pasteHandler: createMarkdownPasteHandler(markdownToBlocks),
386
386
  uploadFile: async (file: File) => {
387
- return `https://placehold.co/600x400?text=${encodeURIComponent(file.name)}`;
387
+ const url = `https://placehold.co/600x400?text=${encodeURIComponent(file.name)}`;
388
+ return {
389
+ props: {
390
+ url,
391
+ name: file.name,
392
+ },
393
+ };
388
394
  },
389
395
  });
390
396
  const [markdown, setMarkdown] = useState("");
@@ -474,8 +480,14 @@ function App() {
474
480
  if (typeof result === "string") {
475
481
  return { url: result };
476
482
  }
477
- if (result && typeof result === "object" && "url" in result && typeof (result as any).url === "string") {
478
- return { url: (result as any).url as string };
483
+ if (result && typeof result === "object") {
484
+ if ("url" in result && typeof (result as any).url === "string") {
485
+ return { url: (result as any).url as string };
486
+ }
487
+ const propsUrl = (result as any).props?.url;
488
+ if (typeof propsUrl === "string") {
489
+ return { url: propsUrl };
490
+ }
479
491
  }
480
492
  throw new Error("uploadFile did not return a URL");
481
493
  }
@@ -512,6 +512,7 @@ export const stepBlock = createReactBlockSpec(
512
512
  onChange={handleStepTitleChange}
513
513
  autoFocus={stepTitle.length === 0}
514
514
  multiline
515
+ disableNewlines
515
516
  enableAutocomplete
516
517
  fieldName="title"
517
518
  suggestionFilter={(suggestion) => (suggestion as StepSuggestion).isSnippet !== true}
@@ -25,6 +25,7 @@ type StepFieldProps = {
25
25
  autoFocus?: boolean;
26
26
  focusSignal?: number;
27
27
  multiline?: boolean;
28
+ disableNewlines?: boolean;
28
29
  enableAutocomplete?: boolean;
29
30
  fieldName?: string;
30
31
  suggestionFilter?: (suggestion: Suggestion) => boolean;
@@ -671,6 +672,7 @@ export function StepField({
671
672
  autoFocus,
672
673
  focusSignal,
673
674
  multiline = false,
675
+ disableNewlines = false,
674
676
  enableAutocomplete = false,
675
677
  fieldName,
676
678
  suggestionFilter,
@@ -1699,6 +1701,12 @@ export function StepField({
1699
1701
  return;
1700
1702
  }
1701
1703
 
1704
+ if (disableNewlines && (event.key === "Enter" || event.code === "Enter")) {
1705
+ event.preventDefault();
1706
+ event.stopImmediatePropagation();
1707
+ return;
1708
+ }
1709
+
1702
1710
  if (event.key === "Tab") {
1703
1711
  const moved = focusAdjacentField(event.shiftKey ? -1 : 1);
1704
1712
  if (moved) {
@@ -1707,7 +1715,7 @@ export function StepField({
1707
1715
  }
1708
1716
  }
1709
1717
  };
1710
- }, [activeSuggestionIndex, applySuggestion, enableAutocomplete, filteredSuggestions, focusAdjacentField, handleToolbarAction, readOnly, shouldShowAutocomplete]);
1718
+ }, [activeSuggestionIndex, applySuggestion, disableNewlines, enableAutocomplete, filteredSuggestions, focusAdjacentField, handleToolbarAction, readOnly, shouldShowAutocomplete]);
1711
1719
 
1712
1720
  useEffect(() => {
1713
1721
  if (!textareaNode) {