@portabletext/editor 1.50.0 → 1.50.2
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/lib/index.cjs +10 -0
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
- package/src/operations/behavior.operation.insert.block.ts +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/editor",
|
|
3
|
-
"version": "1.50.
|
|
3
|
+
"version": "1.50.2",
|
|
4
4
|
"description": "Portable Text Editor made in React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"slate-react": "0.114.2",
|
|
80
80
|
"use-effect-event": "^1.0.2",
|
|
81
81
|
"xstate": "^5.19.2",
|
|
82
|
-
"@portabletext/
|
|
83
|
-
"@portabletext/
|
|
82
|
+
"@portabletext/block-tools": "1.1.26",
|
|
83
|
+
"@portabletext/patches": "1.1.3"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@portabletext/toolkit": "^2.0.17",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"@types/lodash.startcase": "^4.4.9",
|
|
96
96
|
"@types/react": "^19.1.3",
|
|
97
97
|
"@types/react-dom": "^19.1.3",
|
|
98
|
-
"@typescript-eslint/eslint-plugin": "^8.32.
|
|
99
|
-
"@typescript-eslint/parser": "^8.32.
|
|
98
|
+
"@typescript-eslint/eslint-plugin": "^8.32.1",
|
|
99
|
+
"@typescript-eslint/parser": "^8.32.1",
|
|
100
100
|
"@vitejs/plugin-react": "^4.4.1",
|
|
101
101
|
"@vitest/browser": "^3.1.3",
|
|
102
102
|
"@vitest/coverage-istanbul": "^3.1.3",
|
|
@@ -220,6 +220,26 @@ export function insertBlock({
|
|
|
220
220
|
if (editor.isTextBlock(endBlock) && editor.isTextBlock(block)) {
|
|
221
221
|
const selectionStartPoint = Range.start(currentSelection)
|
|
222
222
|
|
|
223
|
+
if (isEqualToEmptyEditor([endBlock], schema)) {
|
|
224
|
+
const currentSelection = editor.selection
|
|
225
|
+
|
|
226
|
+
Transforms.insertNodes(editor, [block], {
|
|
227
|
+
at: endBlockPath,
|
|
228
|
+
select: false,
|
|
229
|
+
})
|
|
230
|
+
Transforms.removeNodes(editor, {at: Path.next(endBlockPath)})
|
|
231
|
+
|
|
232
|
+
if (select === 'start') {
|
|
233
|
+
Transforms.select(editor, selectionStartPoint)
|
|
234
|
+
} else if (select === 'end') {
|
|
235
|
+
Transforms.select(editor, Editor.end(editor, endBlockPath))
|
|
236
|
+
} else {
|
|
237
|
+
Transforms.select(editor, currentSelection)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return
|
|
241
|
+
}
|
|
242
|
+
|
|
223
243
|
if (select === 'end') {
|
|
224
244
|
Transforms.insertFragment(editor, [block], {
|
|
225
245
|
voids: true,
|