@portabletext/editor 1.48.13 → 1.48.15
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/_chunks-cjs/editor-provider.cjs +682 -609
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/editor-provider.js +683 -610
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.d.cts +226 -2772
- package/lib/behaviors/index.d.ts +226 -2772
- package/lib/behaviors/index.js.map +1 -1
- package/lib/index.cjs +22 -6
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +227 -2780
- package/lib/index.d.ts +227 -2780
- package/lib/index.js +23 -7
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +1 -7
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +226 -2785
- package/lib/plugins/index.d.ts +226 -2785
- package/lib/plugins/index.js +2 -8
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.d.cts +225 -2771
- package/lib/selectors/index.d.ts +225 -2771
- package/lib/utils/index.d.cts +227 -2772
- package/lib/utils/index.d.ts +227 -2772
- package/package.json +1 -1
- package/src/behaviors/behavior.abstract.keyboard.ts +16 -0
- package/src/behaviors/{behavior.default.ts → behavior.abstract.ts} +3 -3
- package/src/behaviors/behavior.config.ts +7 -0
- package/src/behaviors/behavior.core.ts +6 -5
- package/src/behaviors/behavior.perform-event.ts +27 -51
- package/src/behaviors/behavior.types.action.ts +1 -11
- package/src/editor/PortableTextEditor.tsx +1 -1
- package/src/editor/components/Element.tsx +30 -4
- package/src/editor/create-editor.ts +17 -5
- package/src/editor/editor-machine.ts +23 -17
- package/src/editor/mutation-machine.ts +6 -6
- package/src/editor/plugins/create-with-event-listeners.ts +25 -25
- package/src/editor/plugins/createWithEditableAPI.ts +3 -3
- package/src/editor/plugins/createWithPatches.ts +13 -5
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +5 -5
- package/src/editor/plugins/createWithUndoRedo.ts +8 -8
- package/src/editor/with-applying-behavior-operations.ts +18 -0
- package/src/editor/{with-applying-behavior-actions.ts → with-undo-step.ts} +1 -19
- package/src/index.ts +1 -1
- package/src/{behavior-actions/behavior.action.annotation.add.ts → operations/behavior.operation.annotation.add.ts} +7 -7
- package/src/{behavior-actions/behavior.action.annotation.remove.ts → operations/behavior.operation.annotation.remove.ts} +6 -6
- package/src/{behavior-actions/behavior.action.block.set.ts → operations/behavior.operation.block.set.ts} +14 -14
- package/src/{behavior-actions/behavior.action.block.unset.ts → operations/behavior.operation.block.unset.ts} +19 -17
- package/src/{behavior-actions/behavior.action.decorator.add.ts → operations/behavior.operation.decorator.add.ts} +10 -10
- package/src/operations/behavior.operation.delete.backward.ts +8 -0
- package/src/operations/behavior.operation.delete.block.ts +24 -0
- package/src/operations/behavior.operation.delete.forward.ts +8 -0
- package/src/{behavior-actions/behavior.action.delete.ts → operations/behavior.operation.delete.ts} +8 -8
- package/src/{behavior-actions/behavior.action.insert-inline-object.ts → operations/behavior.operation.insert-inline-object.ts} +11 -11
- package/src/{behavior-actions/behavior.action.insert-span.ts → operations/behavior.operation.insert-span.ts} +15 -15
- package/src/{behavior-actions/behavior.action.insert.block.ts → operations/behavior.operation.insert.block.ts} +8 -8
- package/src/operations/behavior.operation.insert.text.ts +17 -0
- package/src/operations/behavior.operation.move.backward.ts +12 -0
- package/src/operations/behavior.operation.move.block.ts +16 -0
- package/src/operations/behavior.operation.move.forward.ts +11 -0
- package/src/operations/behavior.operation.select.ts +15 -0
- package/src/operations/behavior.operations.ts +239 -0
- package/src/plugins/index.ts +0 -1
- package/src/priority/priority.core.ts +3 -0
- package/src/priority/priority.sort.test.ts +319 -0
- package/src/priority/priority.sort.ts +121 -0
- package/src/priority/priority.types.ts +24 -0
- package/src/behavior-actions/behavior.action.delete.backward.ts +0 -7
- package/src/behavior-actions/behavior.action.delete.block.ts +0 -24
- package/src/behavior-actions/behavior.action.delete.forward.ts +0 -7
- package/src/behavior-actions/behavior.action.insert.text.ts +0 -17
- package/src/behavior-actions/behavior.action.move.backward.ts +0 -12
- package/src/behavior-actions/behavior.action.move.block.ts +0 -16
- package/src/behavior-actions/behavior.action.move.forward.ts +0 -11
- package/src/behavior-actions/behavior.action.select.ts +0 -15
- package/src/behavior-actions/behavior.actions.ts +0 -219
- package/src/behaviors/behavior.default.raise-soft-break.ts +0 -14
- package/src/plugins/plugin.core.tsx +0 -9
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import type {InternalBehaviorAction} from '../behaviors/behavior.types.action'
|
|
2
|
-
import type {EditorContext} from '../editor/editor-snapshot'
|
|
3
|
-
import {removeDecoratorActionImplementation} from '../editor/plugins/createWithPortableTextMarkModel'
|
|
4
|
-
import {
|
|
5
|
-
historyRedoActionImplementation,
|
|
6
|
-
historyUndoActionImplementation,
|
|
7
|
-
} from '../editor/plugins/createWithUndoRedo'
|
|
8
|
-
import type {PickFromUnion} from '../type-utils'
|
|
9
|
-
import {addAnnotationActionImplementation} from './behavior.action.annotation.add'
|
|
10
|
-
import {removeAnnotationActionImplementation} from './behavior.action.annotation.remove'
|
|
11
|
-
import {blockSetBehaviorActionImplementation} from './behavior.action.block.set'
|
|
12
|
-
import {blockUnsetBehaviorActionImplementation} from './behavior.action.block.unset'
|
|
13
|
-
import {decoratorAddActionImplementation} from './behavior.action.decorator.add'
|
|
14
|
-
import {deleteActionImplementation} from './behavior.action.delete'
|
|
15
|
-
import {deleteBackwardActionImplementation} from './behavior.action.delete.backward'
|
|
16
|
-
import {deleteBlockActionImplementation} from './behavior.action.delete.block'
|
|
17
|
-
import {deleteForwardActionImplementation} from './behavior.action.delete.forward'
|
|
18
|
-
import {insertInlineObjectActionImplementation} from './behavior.action.insert-inline-object'
|
|
19
|
-
import {insertSpanActionImplementation} from './behavior.action.insert-span'
|
|
20
|
-
import {insertBlockActionImplementation} from './behavior.action.insert.block'
|
|
21
|
-
import {insertTextActionImplementation} from './behavior.action.insert.text'
|
|
22
|
-
import {moveBackwardActionImplementation} from './behavior.action.move.backward'
|
|
23
|
-
import {moveBlockActionImplementation} from './behavior.action.move.block'
|
|
24
|
-
import {moveForwardActionImplementation} from './behavior.action.move.forward'
|
|
25
|
-
import {selectActionImplementation} from './behavior.action.select'
|
|
26
|
-
|
|
27
|
-
export type BehaviorActionImplementationContext = Pick<
|
|
28
|
-
EditorContext,
|
|
29
|
-
'keyGenerator' | 'schema'
|
|
30
|
-
>
|
|
31
|
-
|
|
32
|
-
export type BehaviorActionImplementation<
|
|
33
|
-
TBehaviorActionType extends InternalBehaviorAction['type'],
|
|
34
|
-
TReturnType = void,
|
|
35
|
-
> = ({
|
|
36
|
-
context,
|
|
37
|
-
action,
|
|
38
|
-
}: {
|
|
39
|
-
context: BehaviorActionImplementationContext
|
|
40
|
-
action: PickFromUnion<InternalBehaviorAction, 'type', TBehaviorActionType>
|
|
41
|
-
}) => TReturnType
|
|
42
|
-
|
|
43
|
-
type BehaviorActionImplementations = {
|
|
44
|
-
[TBehaviorActionType in InternalBehaviorAction['type']]: BehaviorActionImplementation<TBehaviorActionType>
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const behaviorActionImplementations: BehaviorActionImplementations = {
|
|
48
|
-
'annotation.add': addAnnotationActionImplementation,
|
|
49
|
-
'annotation.remove': removeAnnotationActionImplementation,
|
|
50
|
-
'block.set': blockSetBehaviorActionImplementation,
|
|
51
|
-
'block.unset': blockUnsetBehaviorActionImplementation,
|
|
52
|
-
'decorator.add': decoratorAddActionImplementation,
|
|
53
|
-
'decorator.remove': removeDecoratorActionImplementation,
|
|
54
|
-
'delete': deleteActionImplementation,
|
|
55
|
-
'delete.backward': deleteBackwardActionImplementation,
|
|
56
|
-
'delete.forward': deleteForwardActionImplementation,
|
|
57
|
-
'delete.block': deleteBlockActionImplementation,
|
|
58
|
-
'history.redo': historyRedoActionImplementation,
|
|
59
|
-
'history.undo': historyUndoActionImplementation,
|
|
60
|
-
'insert.block': insertBlockActionImplementation,
|
|
61
|
-
'insert.inline object': insertInlineObjectActionImplementation,
|
|
62
|
-
'insert.span': insertSpanActionImplementation,
|
|
63
|
-
'insert.text': insertTextActionImplementation,
|
|
64
|
-
'move.backward': moveBackwardActionImplementation,
|
|
65
|
-
'move.block': moveBlockActionImplementation,
|
|
66
|
-
'move.forward': moveForwardActionImplementation,
|
|
67
|
-
'select': selectActionImplementation,
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function performAction({
|
|
71
|
-
context,
|
|
72
|
-
action,
|
|
73
|
-
}: {
|
|
74
|
-
context: BehaviorActionImplementationContext
|
|
75
|
-
action: InternalBehaviorAction
|
|
76
|
-
}) {
|
|
77
|
-
switch (action.type) {
|
|
78
|
-
case 'annotation.add': {
|
|
79
|
-
behaviorActionImplementations['annotation.add']({
|
|
80
|
-
context,
|
|
81
|
-
action,
|
|
82
|
-
})
|
|
83
|
-
break
|
|
84
|
-
}
|
|
85
|
-
case 'annotation.remove': {
|
|
86
|
-
behaviorActionImplementations['annotation.remove']({
|
|
87
|
-
context,
|
|
88
|
-
action,
|
|
89
|
-
})
|
|
90
|
-
break
|
|
91
|
-
}
|
|
92
|
-
case 'block.set': {
|
|
93
|
-
behaviorActionImplementations['block.set']({
|
|
94
|
-
context,
|
|
95
|
-
action,
|
|
96
|
-
})
|
|
97
|
-
break
|
|
98
|
-
}
|
|
99
|
-
case 'block.unset': {
|
|
100
|
-
behaviorActionImplementations['block.unset']({
|
|
101
|
-
context,
|
|
102
|
-
action,
|
|
103
|
-
})
|
|
104
|
-
break
|
|
105
|
-
}
|
|
106
|
-
case 'decorator.add': {
|
|
107
|
-
behaviorActionImplementations['decorator.add']({
|
|
108
|
-
context,
|
|
109
|
-
action,
|
|
110
|
-
})
|
|
111
|
-
break
|
|
112
|
-
}
|
|
113
|
-
case 'decorator.remove': {
|
|
114
|
-
behaviorActionImplementations['decorator.remove']({
|
|
115
|
-
context,
|
|
116
|
-
action,
|
|
117
|
-
})
|
|
118
|
-
break
|
|
119
|
-
}
|
|
120
|
-
case 'delete': {
|
|
121
|
-
behaviorActionImplementations.delete({
|
|
122
|
-
context,
|
|
123
|
-
action,
|
|
124
|
-
})
|
|
125
|
-
break
|
|
126
|
-
}
|
|
127
|
-
case 'delete.backward': {
|
|
128
|
-
behaviorActionImplementations['delete.backward']({
|
|
129
|
-
context,
|
|
130
|
-
action,
|
|
131
|
-
})
|
|
132
|
-
break
|
|
133
|
-
}
|
|
134
|
-
case 'delete.block': {
|
|
135
|
-
behaviorActionImplementations['delete.block']({
|
|
136
|
-
context,
|
|
137
|
-
action,
|
|
138
|
-
})
|
|
139
|
-
break
|
|
140
|
-
}
|
|
141
|
-
case 'delete.forward': {
|
|
142
|
-
behaviorActionImplementations['delete.forward']({
|
|
143
|
-
context,
|
|
144
|
-
action,
|
|
145
|
-
})
|
|
146
|
-
break
|
|
147
|
-
}
|
|
148
|
-
case 'history.redo': {
|
|
149
|
-
behaviorActionImplementations['history.redo']({
|
|
150
|
-
context,
|
|
151
|
-
action,
|
|
152
|
-
})
|
|
153
|
-
break
|
|
154
|
-
}
|
|
155
|
-
case 'history.undo': {
|
|
156
|
-
behaviorActionImplementations['history.undo']({
|
|
157
|
-
context,
|
|
158
|
-
action,
|
|
159
|
-
})
|
|
160
|
-
break
|
|
161
|
-
}
|
|
162
|
-
case 'insert.block': {
|
|
163
|
-
behaviorActionImplementations['insert.block']({
|
|
164
|
-
context,
|
|
165
|
-
action,
|
|
166
|
-
})
|
|
167
|
-
break
|
|
168
|
-
}
|
|
169
|
-
case 'insert.inline object': {
|
|
170
|
-
behaviorActionImplementations['insert.inline object']({
|
|
171
|
-
context,
|
|
172
|
-
action,
|
|
173
|
-
})
|
|
174
|
-
break
|
|
175
|
-
}
|
|
176
|
-
case 'insert.span': {
|
|
177
|
-
behaviorActionImplementations['insert.span']({
|
|
178
|
-
context,
|
|
179
|
-
action,
|
|
180
|
-
})
|
|
181
|
-
break
|
|
182
|
-
}
|
|
183
|
-
case 'insert.text': {
|
|
184
|
-
behaviorActionImplementations['insert.text']({
|
|
185
|
-
context,
|
|
186
|
-
action,
|
|
187
|
-
})
|
|
188
|
-
break
|
|
189
|
-
}
|
|
190
|
-
case 'move.backward': {
|
|
191
|
-
behaviorActionImplementations['move.backward']({
|
|
192
|
-
context,
|
|
193
|
-
action,
|
|
194
|
-
})
|
|
195
|
-
break
|
|
196
|
-
}
|
|
197
|
-
case 'move.block': {
|
|
198
|
-
behaviorActionImplementations['move.block']({
|
|
199
|
-
context,
|
|
200
|
-
action,
|
|
201
|
-
})
|
|
202
|
-
break
|
|
203
|
-
}
|
|
204
|
-
case 'move.forward': {
|
|
205
|
-
behaviorActionImplementations['move.forward']({
|
|
206
|
-
context,
|
|
207
|
-
action,
|
|
208
|
-
})
|
|
209
|
-
break
|
|
210
|
-
}
|
|
211
|
-
default: {
|
|
212
|
-
behaviorActionImplementations.select({
|
|
213
|
-
context,
|
|
214
|
-
action,
|
|
215
|
-
})
|
|
216
|
-
break
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {keyIs} from '../internal-utils/key-is'
|
|
2
|
-
import {raise} from './behavior.types.action'
|
|
3
|
-
import {defineBehavior} from './behavior.types.behavior'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* On WebKit, Shift+Enter results in an `insertParagraph` input event rather
|
|
7
|
-
* than an `insertLineBreak` input event. This Behavior makes sure we catch
|
|
8
|
-
* that `keyboard.keydown` event beforehand and raise an `insert.soft break` manually.
|
|
9
|
-
*/
|
|
10
|
-
export const raiseInsertSoftBreak = defineBehavior({
|
|
11
|
-
on: 'keyboard.keydown',
|
|
12
|
-
guard: ({event}) => keyIs.lineBreak(event.originEvent),
|
|
13
|
-
actions: [() => [raise({type: 'insert.soft break'})]],
|
|
14
|
-
})
|