testomatio-editor-blocks 0.4.9 → 0.4.11
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.
|
@@ -81,7 +81,20 @@ export const snippetBlock = createReactBlockSpec({
|
|
|
81
81
|
});
|
|
82
82
|
}, [block.id, editor]);
|
|
83
83
|
const handleFieldFocus = useCallback(() => {
|
|
84
|
-
|
|
84
|
+
var _a, _b, _c;
|
|
85
|
+
const selection = editor.getSelection();
|
|
86
|
+
const blocks = (_a = selection === null || selection === void 0 ? void 0 : selection.blocks) !== null && _a !== void 0 ? _a : [];
|
|
87
|
+
const firstId = (_b = blocks[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
88
|
+
const lastId = (_c = blocks[blocks.length - 1]) === null || _c === void 0 ? void 0 : _c.id;
|
|
89
|
+
if (firstId === block.id && lastId === block.id) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
editor.setSelection(block.id, block.id);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
//
|
|
97
|
+
}
|
|
85
98
|
}, [editor, block.id]);
|
|
86
99
|
if (!hasSnippets) {
|
|
87
100
|
return (_jsx("div", { className: "bn-teststep bn-snippet", "data-block-id": block.id, children: _jsx("p", { className: "bn-snippet__empty", children: "No snippets in this project." }) }));
|
package/package/styles.css
CHANGED
package/package.json
CHANGED
|
@@ -148,7 +148,18 @@ export const snippetBlock = createReactBlockSpec(
|
|
|
148
148
|
);
|
|
149
149
|
|
|
150
150
|
const handleFieldFocus = useCallback(() => {
|
|
151
|
-
editor.
|
|
151
|
+
const selection = editor.getSelection();
|
|
152
|
+
const blocks = selection?.blocks ?? [];
|
|
153
|
+
const firstId = blocks[0]?.id;
|
|
154
|
+
const lastId = blocks[blocks.length - 1]?.id;
|
|
155
|
+
if (firstId === block.id && lastId === block.id) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
editor.setSelection(block.id, block.id);
|
|
160
|
+
} catch {
|
|
161
|
+
//
|
|
162
|
+
}
|
|
152
163
|
}, [editor, block.id]);
|
|
153
164
|
|
|
154
165
|
if (!hasSnippets) {
|