@portabletext/editor 1.50.0 → 1.50.1
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/behaviors/index.d.cts +3 -0
- package/lib/behaviors/index.d.ts +3 -0
- package/lib/index.cjs +10 -0
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +3 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.cts +3 -0
- package/lib/plugins/index.d.ts +3 -0
- package/lib/selectors/index.d.cts +3 -0
- package/lib/selectors/index.d.ts +3 -0
- package/lib/utils/index.d.cts +3 -0
- package/lib/utils/index.d.ts +3 -0
- package/package.json +5 -5
- package/src/editor/editor-machine.ts +3 -0
- package/src/operations/behavior.operation.insert.block.ts +20 -0
package/lib/plugins/index.d.cts
CHANGED
|
@@ -2901,6 +2901,9 @@ export declare function OneLinePlugin(): JSX.Element
|
|
|
2901
2901
|
declare type PatchesEvent = {
|
|
2902
2902
|
type: 'patches'
|
|
2903
2903
|
patches: Array<Patch>
|
|
2904
|
+
/**
|
|
2905
|
+
* @deprecated Unused by the editor
|
|
2906
|
+
*/
|
|
2904
2907
|
snapshot: Array<PortableTextBlock> | undefined
|
|
2905
2908
|
}
|
|
2906
2909
|
|
package/lib/plugins/index.d.ts
CHANGED
|
@@ -2901,6 +2901,9 @@ export declare function OneLinePlugin(): JSX.Element
|
|
|
2901
2901
|
declare type PatchesEvent = {
|
|
2902
2902
|
type: 'patches'
|
|
2903
2903
|
patches: Array<Patch>
|
|
2904
|
+
/**
|
|
2905
|
+
* @deprecated Unused by the editor
|
|
2906
|
+
*/
|
|
2904
2907
|
snapshot: Array<PortableTextBlock> | undefined
|
|
2905
2908
|
}
|
|
2906
2909
|
|
|
@@ -3006,6 +3006,9 @@ declare type ObjectBlockWithOptionalKey = Omit<PortableTextObject, '_key'> & {
|
|
|
3006
3006
|
declare type PatchesEvent = {
|
|
3007
3007
|
type: 'patches'
|
|
3008
3008
|
patches: Array<Patch>
|
|
3009
|
+
/**
|
|
3010
|
+
* @deprecated Unused by the editor
|
|
3011
|
+
*/
|
|
3009
3012
|
snapshot: Array<PortableTextBlock> | undefined
|
|
3010
3013
|
}
|
|
3011
3014
|
|
package/lib/selectors/index.d.ts
CHANGED
|
@@ -3006,6 +3006,9 @@ declare type ObjectBlockWithOptionalKey = Omit<PortableTextObject, '_key'> & {
|
|
|
3006
3006
|
declare type PatchesEvent = {
|
|
3007
3007
|
type: 'patches'
|
|
3008
3008
|
patches: Array<Patch>
|
|
3009
|
+
/**
|
|
3010
|
+
* @deprecated Unused by the editor
|
|
3011
|
+
*/
|
|
3009
3012
|
snapshot: Array<PortableTextBlock> | undefined
|
|
3010
3013
|
}
|
|
3011
3014
|
|
package/lib/utils/index.d.cts
CHANGED
|
@@ -2767,6 +2767,9 @@ declare type ObjectBlockWithOptionalKey = Omit<PortableTextObject, '_key'> & {
|
|
|
2767
2767
|
declare type PatchesEvent = {
|
|
2768
2768
|
type: 'patches'
|
|
2769
2769
|
patches: Array<Patch>
|
|
2770
|
+
/**
|
|
2771
|
+
* @deprecated Unused by the editor
|
|
2772
|
+
*/
|
|
2770
2773
|
snapshot: Array<PortableTextBlock> | undefined
|
|
2771
2774
|
}
|
|
2772
2775
|
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -2767,6 +2767,9 @@ declare type ObjectBlockWithOptionalKey = Omit<PortableTextObject, '_key'> & {
|
|
|
2767
2767
|
declare type PatchesEvent = {
|
|
2768
2768
|
type: 'patches'
|
|
2769
2769
|
patches: Array<Patch>
|
|
2770
|
+
/**
|
|
2771
|
+
* @deprecated Unused by the editor
|
|
2772
|
+
*/
|
|
2770
2773
|
snapshot: Array<PortableTextBlock> | undefined
|
|
2771
2774
|
}
|
|
2772
2775
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/editor",
|
|
3
|
-
"version": "1.50.
|
|
3
|
+
"version": "1.50.1",
|
|
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,
|