@portabletext/editor 1.45.0 → 1.45.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.
Files changed (37) hide show
  1. package/lib/_chunks-cjs/behavior.markdown.cjs +9 -9
  2. package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
  3. package/lib/_chunks-cjs/editor-provider.cjs +36 -39
  4. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  5. package/lib/_chunks-es/behavior.markdown.js +10 -10
  6. package/lib/_chunks-es/behavior.markdown.js.map +1 -1
  7. package/lib/_chunks-es/editor-provider.js +36 -39
  8. package/lib/_chunks-es/editor-provider.js.map +1 -1
  9. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +1 -1
  10. package/lib/behaviors/index.cjs +4 -4
  11. package/lib/behaviors/index.cjs.map +1 -1
  12. package/lib/behaviors/index.d.cts +282 -282
  13. package/lib/behaviors/index.d.ts +282 -282
  14. package/lib/behaviors/index.js +4 -4
  15. package/lib/behaviors/index.js.map +1 -1
  16. package/lib/index.d.cts +8 -8
  17. package/lib/index.d.ts +8 -8
  18. package/lib/plugins/index.cjs +4 -4
  19. package/lib/plugins/index.cjs.map +1 -1
  20. package/lib/plugins/index.d.cts +8 -8
  21. package/lib/plugins/index.d.ts +8 -8
  22. package/lib/plugins/index.js +4 -4
  23. package/lib/plugins/index.js.map +1 -1
  24. package/lib/selectors/index.d.cts +8 -8
  25. package/lib/selectors/index.d.ts +8 -8
  26. package/lib/utils/index.d.cts +8 -8
  27. package/lib/utils/index.d.ts +8 -8
  28. package/package.json +1 -1
  29. package/src/behavior-actions/behavior.action.insert.text.ts +2 -1
  30. package/src/behavior-actions/behavior.actions.ts +0 -9
  31. package/src/behaviors/behavior.abstract.delete.ts +42 -0
  32. package/src/behaviors/behavior.decorator-pair.ts +5 -4
  33. package/src/behaviors/behavior.default.ts +2 -0
  34. package/src/behaviors/behavior.emoji-picker.ts +5 -4
  35. package/src/behaviors/behavior.markdown.ts +10 -9
  36. package/src/behaviors/behavior.types.event.ts +8 -8
  37. package/src/behavior-actions/behavior.action.delete.text.ts +0 -53
@@ -68,7 +68,6 @@ const syntheticBehaviorEventTypes = [
68
68
  'delete.backward',
69
69
  'delete.block',
70
70
  'delete.forward',
71
- 'delete.text',
72
71
  'focus',
73
72
  'history.redo',
74
73
  'history.undo',
@@ -144,13 +143,6 @@ export type SyntheticBehaviorEvent =
144
143
  type: StrictExtract<SyntheticBehaviorEventType, 'delete.forward'>
145
144
  unit: TextUnit
146
145
  }
147
- | {
148
- type: StrictExtract<SyntheticBehaviorEventType, 'delete.text'>
149
- at: {
150
- anchor: BlockOffset
151
- focus: BlockOffset
152
- }
153
- }
154
146
  | {
155
147
  type: StrictExtract<SyntheticBehaviorEventType, 'focus'>
156
148
  }
@@ -214,6 +206,7 @@ export function isKeyboardBehaviorEvent(
214
206
  const abstractBehaviorEventTypes = [
215
207
  'annotation.toggle',
216
208
  'decorator.toggle',
209
+ 'delete.text',
217
210
  'deserialize',
218
211
  'deserialization.success',
219
212
  'deserialization.failure',
@@ -253,6 +246,13 @@ export type AbstractBehaviorEvent =
253
246
  decorator: string
254
247
  at?: {anchor: BlockOffset; focus: BlockOffset}
255
248
  }
249
+ | {
250
+ type: StrictExtract<AbstractBehaviorEventType, 'delete.text'>
251
+ at: {
252
+ anchor: BlockOffset
253
+ focus: BlockOffset
254
+ }
255
+ }
256
256
  | {
257
257
  type: StrictExtract<AbstractBehaviorEventType, 'deserialize'>
258
258
  originEvent:
@@ -1,53 +0,0 @@
1
- import {Transforms} from 'slate'
2
- import {toSlateRange} from '../internal-utils/ranges'
3
- import {fromSlateValue} from '../internal-utils/values'
4
- import {KEY_TO_VALUE_ELEMENT} from '../internal-utils/weakMaps'
5
- import * as selectors from '../selectors'
6
- import * as utils from '../utils'
7
- import type {BehaviorActionImplementation} from './behavior.actions'
8
-
9
- export const deleteTextActionImplementation: BehaviorActionImplementation<
10
- 'delete.text'
11
- > = ({context, action}) => {
12
- const value = fromSlateValue(
13
- action.editor.children,
14
- context.schema.block.name,
15
- KEY_TO_VALUE_ELEMENT.get(action.editor),
16
- )
17
-
18
- const selection = utils.blockOffsetsToSelection({
19
- value,
20
- offsets: action.at,
21
- })
22
-
23
- if (!selection) {
24
- throw new Error('Unable to find selection from block offsets')
25
- }
26
-
27
- const trimmedSelection = selectors.getTrimmedSelection({
28
- beta: {hasTag: () => false, internalDrag: undefined},
29
- context: {
30
- converters: [],
31
- schema: context.schema,
32
- keyGenerator: context.keyGenerator,
33
- activeDecorators: [],
34
- readOnly: false,
35
- value,
36
- selection,
37
- },
38
- })
39
-
40
- if (!trimmedSelection) {
41
- throw new Error('Unable to find trimmed selection')
42
- }
43
-
44
- const range = toSlateRange(trimmedSelection, action.editor)
45
-
46
- if (!range) {
47
- throw new Error('Unable to find Slate range from trimmed selection')
48
- }
49
-
50
- Transforms.delete(action.editor, {
51
- at: range,
52
- })
53
- }