@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "1.11.0",
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.2",
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.2",
65
- "@sanity/types": "^3.64.2",
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.2",
94
- "@sanity/schema": "^3.64.2",
95
- "@sanity/types": "^3.64.2",
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 {BehaviourActionImplementation} from './behavior.actions'
4
+ import type {BehaviorActionImplementation} from './behavior.actions'
5
5
 
6
- export const insertBreakActionImplementation: BehaviourActionImplementation<
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: BehaviourActionImplementation<
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 {BehaviourActionImplementation} from './behavior.actions'
2
+ import type {BehaviorActionImplementation} from './behavior.actions'
3
3
 
4
- export const insertSpanActionImplementation: BehaviourActionImplementation<
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 BehaviourActionImplementation<
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 BehaviourActionImplementations = {
50
- [TBehaviorActionType in BehaviorAction['type']]: BehaviourActionImplementation<TBehaviorActionType>
49
+ type BehaviorActionImplementations = {
50
+ [TBehaviorActionType in BehaviorAction['type']]: BehaviorActionImplementation<TBehaviorActionType>
51
51
  }
52
52
 
53
- const behaviorActionImplementations: BehaviourActionImplementations = {
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
- actionIntends.length > 0 &&
293
- actionIntends.some((actionIntend) => actionIntend.type !== 'effect')
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 {BehaviourActionImplementation} from '../behavior/behavior.actions'
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: BehaviourActionImplementation<
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: BehaviourActionImplementation<
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: BehaviourActionImplementation<
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: BehaviourActionImplementation<
913
+ export const toggleAnnotationActionImplementation: BehaviorActionImplementation<
914
914
  'annotation.toggle',
915
915
  AddedAnnotationPaths | undefined
916
916
  > = ({context, action}) => {
@@ -14,6 +14,7 @@ export function createWithMaxBlocks(editorActor: EditorActor) {
14
14
  const {apply} = editor
15
15
  editor.apply = (operation) => {
16
16
  if (editorActor.getSnapshot().context.readOnly) {
17
+ apply(operation)
17
18
  return
18
19
  }
19
20
 
@@ -22,6 +22,7 @@ export function createWithPlaceholderBlock(
22
22
 
23
23
  editor.apply = (op) => {
24
24
  if (editorActor.getSnapshot().context.readOnly) {
25
+ apply(op)
25
26
  return
26
27
  }
27
28
 
@@ -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 {BehaviourActionImplementation} from '../behavior/behavior.actions'
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: BehaviourActionImplementation<
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: BehaviourActionImplementation<
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: BehaviourActionImplementation<
863
+ export const toggleDecoratorActionImplementation: BehaviorActionImplementation<
864
864
  'decorator.toggle'
865
865
  > = ({context, action}) => {
866
866
  const isActive = isDecoratorActive({
@@ -115,6 +115,7 @@ export function createWithUndoRedo(
115
115
  const {apply} = editor
116
116
  editor.apply = (op: Operation) => {
117
117
  if (editorActor.getSnapshot().context.readOnly) {
118
+ apply(op)
118
119
  return
119
120
  }
120
121