@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.
@@ -80,8 +80,7 @@ export function createWithUndoRedo(
80
80
  blockSchemaType.name,
81
81
  )
82
82
  const remotePatches = getRemotePatches(editor)
83
- let previousBehaviorActionIntendSetId =
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 currentBehaviorActionIntendSetId =
155
- getCurrentBehaviorActionSetId(editor)
153
+ const currentBehaviorActionSetId = getCurrentBehaviorActionSetId(editor)
156
154
 
157
155
  let merge =
158
- currentBehaviorActionIntendSetId !== undefined &&
159
- previousBehaviorActionIntendSetId === undefined
156
+ currentBehaviorActionSetId !== undefined &&
157
+ previousBehaviorActionSetId === undefined
160
158
  ? false
161
- : currentBehaviorActionIntendSetId !== undefined &&
162
- previousBehaviorActionIntendSetId !== undefined
163
- ? currentBehaviorActionIntendSetId ===
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
- currentBehaviorActionIntendSetId === undefined &&
173
- previousBehaviorActionIntendSetId === undefined
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
- previousBehaviorActionIntendSetId = currentBehaviorActionIntendSetId
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 CURRENT_BEHAVIOR_ACTION_INTEND_SET: WeakMap<
22
+ const CURRENT_BEHAVIOR_ACTION_SET: WeakMap<
23
23
  Editor,
24
24
  {actionSetId: string} | undefined
25
25
  > = new WeakMap()
26
26
 
27
- export function withApplyingBehaviorActionIntendSet(
28
- editor: Editor,
29
- fn: () => void,
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
- CURRENT_BEHAVIOR_ACTION_INTEND_SET.set(editor, current)
33
+ CURRENT_BEHAVIOR_ACTION_SET.set(editor, current)
37
34
  }
38
35
 
39
36
  export function getCurrentBehaviorActionSetId(editor: Editor) {
40
- return CURRENT_BEHAVIOR_ACTION_INTEND_SET.get(editor)?.actionSetId
37
+ return CURRENT_BEHAVIOR_ACTION_SET.get(editor)?.actionSetId
41
38
  }
@@ -1,8 +1,8 @@
1
- export function createTestKeyGenerator() {
1
+ export function createTestKeyGenerator(prefix?: string) {
2
2
  let index = 0
3
3
 
4
4
  return function keyGenerator() {
5
- const key = `k${index}`
5
+ const key = `${prefix ?? ''}k${index}`
6
6
  index++
7
7
  return key
8
8
  }