@portabletext/editor 1.36.3 → 1.36.5
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/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +23 -23
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +23 -23
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/behaviors/index.d.cts +5 -5
- package/lib/behaviors/index.d.ts +5 -5
- package/lib/index.d.cts +4 -4
- package/lib/index.d.ts +4 -4
- package/lib/plugins/index.d.cts +4 -4
- package/lib/plugins/index.d.ts +4 -4
- package/lib/selectors/index.d.cts +4 -4
- package/lib/selectors/index.d.ts +4 -4
- package/lib/utils/index.d.cts +4 -4
- package/lib/utils/index.d.ts +4 -4
- package/package.json +14 -11
- package/src/behavior-actions/behavior.actions.ts +10 -6
- package/src/behaviors/behavior.types.ts +7 -10
- package/src/behaviors/index.ts +2 -2
- package/src/editor/editor-machine.ts +18 -20
- package/src/editor/plugins/createWithUndoRedo.ts +10 -13
- package/src/editor/with-applying-behavior-actions.ts +6 -9
- package/src/internal-utils/test-key-generator.ts +2 -2
|
@@ -80,8 +80,7 @@ export function createWithUndoRedo(
|
|
|
80
80
|
blockSchemaType.name,
|
|
81
81
|
)
|
|
82
82
|
const remotePatches = getRemotePatches(editor)
|
|
83
|
-
let
|
|
84
|
-
getCurrentBehaviorActionSetId(editor)
|
|
83
|
+
let previousBehaviorActionSetId = getCurrentBehaviorActionSetId(editor)
|
|
85
84
|
|
|
86
85
|
options.subscriptions.push(() => {
|
|
87
86
|
debug('Subscribing to patches')
|
|
@@ -151,17 +150,15 @@ export function createWithUndoRedo(
|
|
|
151
150
|
const overwrite = shouldOverwrite(op, lastOp)
|
|
152
151
|
const save = isSaving(editor)
|
|
153
152
|
|
|
154
|
-
const
|
|
155
|
-
getCurrentBehaviorActionSetId(editor)
|
|
153
|
+
const currentBehaviorActionSetId = getCurrentBehaviorActionSetId(editor)
|
|
156
154
|
|
|
157
155
|
let merge =
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
currentBehaviorActionSetId !== undefined &&
|
|
157
|
+
previousBehaviorActionSetId === undefined
|
|
160
158
|
? false
|
|
161
|
-
:
|
|
162
|
-
|
|
163
|
-
?
|
|
164
|
-
previousBehaviorActionIntendSetId
|
|
159
|
+
: currentBehaviorActionSetId !== undefined &&
|
|
160
|
+
previousBehaviorActionSetId !== undefined
|
|
161
|
+
? currentBehaviorActionSetId === previousBehaviorActionSetId
|
|
165
162
|
: true
|
|
166
163
|
|
|
167
164
|
if (save) {
|
|
@@ -169,8 +166,8 @@ export function createWithUndoRedo(
|
|
|
169
166
|
merge = false
|
|
170
167
|
} else if (operations.length === 0) {
|
|
171
168
|
merge =
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
currentBehaviorActionSetId === undefined &&
|
|
170
|
+
previousBehaviorActionSetId === undefined
|
|
174
171
|
? shouldMerge(op, lastOp) || overwrite
|
|
175
172
|
: merge
|
|
176
173
|
}
|
|
@@ -200,7 +197,7 @@ export function createWithUndoRedo(
|
|
|
200
197
|
}
|
|
201
198
|
}
|
|
202
199
|
|
|
203
|
-
|
|
200
|
+
previousBehaviorActionSetId = currentBehaviorActionSetId
|
|
204
201
|
|
|
205
202
|
apply(op)
|
|
206
203
|
}
|
|
@@ -19,23 +19,20 @@ export function isApplyingBehaviorActions(editor: Editor) {
|
|
|
19
19
|
|
|
20
20
|
////////
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const CURRENT_BEHAVIOR_ACTION_SET: WeakMap<
|
|
23
23
|
Editor,
|
|
24
24
|
{actionSetId: string} | undefined
|
|
25
25
|
> = new WeakMap()
|
|
26
26
|
|
|
27
|
-
export function
|
|
28
|
-
editor
|
|
29
|
-
|
|
30
|
-
) {
|
|
31
|
-
const current = CURRENT_BEHAVIOR_ACTION_INTEND_SET.get(editor)
|
|
32
|
-
CURRENT_BEHAVIOR_ACTION_INTEND_SET.set(editor, {
|
|
27
|
+
export function withApplyingBehaviorActionSet(editor: Editor, fn: () => void) {
|
|
28
|
+
const current = CURRENT_BEHAVIOR_ACTION_SET.get(editor)
|
|
29
|
+
CURRENT_BEHAVIOR_ACTION_SET.set(editor, {
|
|
33
30
|
actionSetId: defaultKeyGenerator(),
|
|
34
31
|
})
|
|
35
32
|
withApplyingBehaviorActions(editor, fn)
|
|
36
|
-
|
|
33
|
+
CURRENT_BEHAVIOR_ACTION_SET.set(editor, current)
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
export function getCurrentBehaviorActionSetId(editor: Editor) {
|
|
40
|
-
return
|
|
37
|
+
return CURRENT_BEHAVIOR_ACTION_SET.get(editor)?.actionSetId
|
|
41
38
|
}
|