@portabletext/editor 1.11.0 → 1.11.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/README.md +10 -1
- package/lib/index.esm.js +27 -21
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +27 -21
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +27 -21
- package/lib/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/editor/behavior/behavior.action.insert-break.ts +3 -3
- package/src/editor/behavior/behavior.action.insert-span.ts +2 -2
- package/src/editor/behavior/behavior.actions.ts +4 -4
- package/src/editor/editor-machine.ts +5 -2
- package/src/editor/plugins/createWithEditableAPI.ts +5 -5
- package/src/editor/plugins/createWithMaxBlocks.ts +1 -0
- package/src/editor/plugins/createWithPlaceholderBlock.ts +1 -0
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +4 -4
- package/src/editor/plugins/createWithUndoRedo.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/editor",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"description": "Portable Text Editor made in React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@portabletext/toolkit": "^2.0.16",
|
|
61
|
-
"@sanity/block-tools": "^3.64.
|
|
61
|
+
"@sanity/block-tools": "^3.64.3",
|
|
62
62
|
"@sanity/diff-match-patch": "^3.1.1",
|
|
63
63
|
"@sanity/pkg-utils": "^6.11.12",
|
|
64
|
-
"@sanity/schema": "^3.64.
|
|
65
|
-
"@sanity/types": "^3.64.
|
|
64
|
+
"@sanity/schema": "^3.64.3",
|
|
65
|
+
"@sanity/types": "^3.64.3",
|
|
66
66
|
"@testing-library/jest-dom": "^6.6.3",
|
|
67
67
|
"@testing-library/react": "^16.0.1",
|
|
68
68
|
"@types/debug": "^4.1.5",
|
|
@@ -90,9 +90,9 @@
|
|
|
90
90
|
"@sanity/gherkin-driver": "^0.0.1"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
|
-
"@sanity/block-tools": "^3.64.
|
|
94
|
-
"@sanity/schema": "^3.64.
|
|
95
|
-
"@sanity/types": "^3.64.
|
|
93
|
+
"@sanity/block-tools": "^3.64.3",
|
|
94
|
+
"@sanity/schema": "^3.64.3",
|
|
95
|
+
"@sanity/types": "^3.64.3",
|
|
96
96
|
"react": "^16.9 || ^17 || ^18",
|
|
97
97
|
"rxjs": "^7.8.1",
|
|
98
98
|
"styled-components": "^6.1.13"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {isEqual} from 'lodash'
|
|
2
2
|
import {Editor, Node, Path, Range, Transforms} from 'slate'
|
|
3
3
|
import type {SlateTextBlock, VoidElement} from '../../types/slate'
|
|
4
|
-
import type {
|
|
4
|
+
import type {BehaviorActionImplementation} from './behavior.actions'
|
|
5
5
|
|
|
6
|
-
export const insertBreakActionImplementation:
|
|
6
|
+
export const insertBreakActionImplementation: BehaviorActionImplementation<
|
|
7
7
|
'insert break'
|
|
8
8
|
> = ({context, action}) => {
|
|
9
9
|
const keyGenerator = context.keyGenerator
|
|
@@ -204,7 +204,7 @@ export const insertBreakActionImplementation: BehaviourActionImplementation<
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
export const insertSoftBreakActionImplementation:
|
|
207
|
+
export const insertSoftBreakActionImplementation: BehaviorActionImplementation<
|
|
208
208
|
'insert soft break'
|
|
209
209
|
> = ({context, action}) => {
|
|
210
210
|
// This mimics Slate's internal which also just does a regular insert break
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Editor, Transforms} from 'slate'
|
|
2
|
-
import type {
|
|
2
|
+
import type {BehaviorActionImplementation} from './behavior.actions'
|
|
3
3
|
|
|
4
|
-
export const insertSpanActionImplementation:
|
|
4
|
+
export const insertSpanActionImplementation: BehaviorActionImplementation<
|
|
5
5
|
'insert span'
|
|
6
6
|
> = ({context, action}) => {
|
|
7
7
|
if (!action.editor.selection) {
|
|
@@ -35,7 +35,7 @@ export type BehaviorActionContext = {
|
|
|
35
35
|
schema: PortableTextMemberSchemaTypes
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export type
|
|
38
|
+
export type BehaviorActionImplementation<
|
|
39
39
|
TBehaviorActionType extends BehaviorAction['type'],
|
|
40
40
|
TReturnType = void,
|
|
41
41
|
> = ({
|
|
@@ -46,11 +46,11 @@ export type BehaviourActionImplementation<
|
|
|
46
46
|
action: PickFromUnion<BehaviorAction, 'type', TBehaviorActionType>
|
|
47
47
|
}) => TReturnType
|
|
48
48
|
|
|
49
|
-
type
|
|
50
|
-
[TBehaviorActionType in BehaviorAction['type']]:
|
|
49
|
+
type BehaviorActionImplementations = {
|
|
50
|
+
[TBehaviorActionType in BehaviorAction['type']]: BehaviorActionImplementation<TBehaviorActionType>
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const behaviorActionImplementations:
|
|
53
|
+
const behaviorActionImplementations: BehaviorActionImplementations = {
|
|
54
54
|
'annotation.add': addAnnotationActionImplementation,
|
|
55
55
|
'annotation.remove': removeAnnotationActionImplementation,
|
|
56
56
|
'annotation.toggle': toggleAnnotationActionImplementation,
|
|
@@ -289,8 +289,11 @@ export const editorMachine = setup({
|
|
|
289
289
|
|
|
290
290
|
for (const actionIntends of actionIntendSets) {
|
|
291
291
|
behaviorOverwritten =
|
|
292
|
-
|
|
293
|
-
actionIntends.
|
|
292
|
+
behaviorOverwritten ||
|
|
293
|
+
(actionIntends.length > 0 &&
|
|
294
|
+
actionIntends.some(
|
|
295
|
+
(actionIntend) => actionIntend.type !== 'effect',
|
|
296
|
+
))
|
|
294
297
|
|
|
295
298
|
enqueue.raise({
|
|
296
299
|
type: 'behavior action intends',
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
KEY_TO_VALUE_ELEMENT,
|
|
36
36
|
SLATE_TO_PORTABLE_TEXT_RANGE,
|
|
37
37
|
} from '../../utils/weakMaps'
|
|
38
|
-
import type {
|
|
38
|
+
import type {BehaviorActionImplementation} from '../behavior/behavior.actions'
|
|
39
39
|
import type {EditorActor} from '../editor-machine'
|
|
40
40
|
import {isDecoratorActive} from './createWithPortableTextMarkModel'
|
|
41
41
|
|
|
@@ -487,7 +487,7 @@ export function createEditableAPI(
|
|
|
487
487
|
return editableApi
|
|
488
488
|
}
|
|
489
489
|
|
|
490
|
-
export const insertBlockObjectActionImplementation:
|
|
490
|
+
export const insertBlockObjectActionImplementation: BehaviorActionImplementation<
|
|
491
491
|
'insert block object',
|
|
492
492
|
Path
|
|
493
493
|
> = ({context, action}) => {
|
|
@@ -640,7 +640,7 @@ export type AddedAnnotationPaths = {
|
|
|
640
640
|
spanPath: Path
|
|
641
641
|
}
|
|
642
642
|
|
|
643
|
-
export const addAnnotationActionImplementation:
|
|
643
|
+
export const addAnnotationActionImplementation: BehaviorActionImplementation<
|
|
644
644
|
'annotation.add',
|
|
645
645
|
AddedAnnotationPaths | undefined
|
|
646
646
|
> = ({context, action}) => {
|
|
@@ -761,7 +761,7 @@ export const addAnnotationActionImplementation: BehaviourActionImplementation<
|
|
|
761
761
|
return paths
|
|
762
762
|
}
|
|
763
763
|
|
|
764
|
-
export const removeAnnotationActionImplementation:
|
|
764
|
+
export const removeAnnotationActionImplementation: BehaviorActionImplementation<
|
|
765
765
|
'annotation.remove'
|
|
766
766
|
> = ({action}) => {
|
|
767
767
|
const editor = action.editor
|
|
@@ -910,7 +910,7 @@ export const removeAnnotationActionImplementation: BehaviourActionImplementation
|
|
|
910
910
|
}
|
|
911
911
|
}
|
|
912
912
|
|
|
913
|
-
export const toggleAnnotationActionImplementation:
|
|
913
|
+
export const toggleAnnotationActionImplementation: BehaviorActionImplementation<
|
|
914
914
|
'annotation.toggle',
|
|
915
915
|
AddedAnnotationPaths | undefined
|
|
916
916
|
> = ({context, action}) => {
|
|
@@ -16,7 +16,7 @@ import {debugWithName} from '../../utils/debug'
|
|
|
16
16
|
import {getNextSpan, getPreviousSpan} from '../../utils/sibling-utils'
|
|
17
17
|
import {isChangingRemotely} from '../../utils/withChanges'
|
|
18
18
|
import {isRedoing, isUndoing} from '../../utils/withUndoRedo'
|
|
19
|
-
import type {
|
|
19
|
+
import type {BehaviorActionImplementation} from '../behavior/behavior.actions'
|
|
20
20
|
import type {EditorActor} from '../editor-machine'
|
|
21
21
|
|
|
22
22
|
const debug = debugWithName('plugin:withPortableTextMarkModel')
|
|
@@ -654,7 +654,7 @@ export function createWithPortableTextMarkModel(
|
|
|
654
654
|
}
|
|
655
655
|
}
|
|
656
656
|
|
|
657
|
-
export const addDecoratorActionImplementation:
|
|
657
|
+
export const addDecoratorActionImplementation: BehaviorActionImplementation<
|
|
658
658
|
'decorator.add'
|
|
659
659
|
> = ({action}) => {
|
|
660
660
|
const editor = action.editor
|
|
@@ -745,7 +745,7 @@ export const addDecoratorActionImplementation: BehaviourActionImplementation<
|
|
|
745
745
|
}
|
|
746
746
|
}
|
|
747
747
|
|
|
748
|
-
export const removeDecoratorActionImplementation:
|
|
748
|
+
export const removeDecoratorActionImplementation: BehaviorActionImplementation<
|
|
749
749
|
'decorator.remove'
|
|
750
750
|
> = ({action}) => {
|
|
751
751
|
const editor = action.editor
|
|
@@ -860,7 +860,7 @@ export function isDecoratorActive({
|
|
|
860
860
|
).includes(decorator)
|
|
861
861
|
}
|
|
862
862
|
|
|
863
|
-
export const toggleDecoratorActionImplementation:
|
|
863
|
+
export const toggleDecoratorActionImplementation: BehaviorActionImplementation<
|
|
864
864
|
'decorator.toggle'
|
|
865
865
|
> = ({context, action}) => {
|
|
866
866
|
const isActive = isDecoratorActive({
|