@portabletext/editor 1.44.16 → 1.45.1

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 (63) hide show
  1. package/lib/_chunks-cjs/behavior.core.cjs +5 -5
  2. package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
  3. package/lib/_chunks-cjs/behavior.markdown.cjs +29 -23
  4. package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
  5. package/lib/_chunks-cjs/editor-provider.cjs +62 -38
  6. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  7. package/lib/_chunks-cjs/parse-blocks.cjs +74 -22
  8. package/lib/_chunks-cjs/parse-blocks.cjs.map +1 -1
  9. package/lib/_chunks-es/behavior.core.js +5 -5
  10. package/lib/_chunks-es/behavior.core.js.map +1 -1
  11. package/lib/_chunks-es/behavior.markdown.js +29 -23
  12. package/lib/_chunks-es/behavior.markdown.js.map +1 -1
  13. package/lib/_chunks-es/editor-provider.js +63 -39
  14. package/lib/_chunks-es/editor-provider.js.map +1 -1
  15. package/lib/_chunks-es/parse-blocks.js +75 -23
  16. package/lib/_chunks-es/parse-blocks.js.map +1 -1
  17. package/lib/behaviors/index.cjs +18 -14
  18. package/lib/behaviors/index.cjs.map +1 -1
  19. package/lib/behaviors/index.d.cts +53 -41
  20. package/lib/behaviors/index.d.ts +53 -41
  21. package/lib/behaviors/index.js +18 -14
  22. package/lib/behaviors/index.js.map +1 -1
  23. package/lib/index.cjs +1 -1
  24. package/lib/index.cjs.map +1 -1
  25. package/lib/index.d.cts +28 -9
  26. package/lib/index.d.ts +28 -9
  27. package/lib/index.js +1 -1
  28. package/lib/index.js.map +1 -1
  29. package/lib/plugins/index.cjs +7 -7
  30. package/lib/plugins/index.cjs.map +1 -1
  31. package/lib/plugins/index.d.cts +8 -6
  32. package/lib/plugins/index.d.ts +8 -6
  33. package/lib/plugins/index.js +7 -7
  34. package/lib/plugins/index.js.map +1 -1
  35. package/lib/selectors/index.d.cts +8 -6
  36. package/lib/selectors/index.d.ts +8 -6
  37. package/lib/utils/index.d.cts +8 -6
  38. package/lib/utils/index.d.ts +8 -6
  39. package/package.json +3 -3
  40. package/src/behavior-actions/behavior.action.annotation.add.ts +26 -5
  41. package/src/behavior-actions/behavior.action.decorator.add.ts +4 -4
  42. package/src/behavior-actions/behavior.action.delete.text.ts +1 -4
  43. package/src/behavior-actions/behavior.action.delete.ts +2 -2
  44. package/src/behavior-actions/behavior.action.insert-inline-object.ts +14 -13
  45. package/src/behavior-actions/behavior.action.select.ts +1 -1
  46. package/src/behaviors/behavior.abstract.decorator.ts +2 -2
  47. package/src/behaviors/behavior.abstract.select.ts +2 -2
  48. package/src/behaviors/behavior.core.annotations.ts +1 -1
  49. package/src/behaviors/behavior.core.block-objects.ts +4 -4
  50. package/src/behaviors/behavior.decorator-pair.ts +3 -3
  51. package/src/behaviors/behavior.default.ts +4 -4
  52. package/src/behaviors/behavior.emoji-picker.ts +18 -14
  53. package/src/behaviors/behavior.markdown.ts +29 -23
  54. package/src/behaviors/behavior.types.event.ts +11 -6
  55. package/src/converters/converter.portable-text.deserialize.test.ts +12 -3
  56. package/src/converters/converter.text-html.deserialize.test.ts +3 -1
  57. package/src/editor/Editable.tsx +1 -1
  58. package/src/editor/define-schema.ts +29 -5
  59. package/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx +2 -2
  60. package/src/editor/plugins/create-with-event-listeners.ts +1 -1
  61. package/src/internal-utils/parse-blocks.ts +109 -39
  62. package/src/plugins/plugin.decorator-shortcut.ts +3 -3
  63. package/src/plugins/plugin.one-line.tsx +1 -1
package/lib/index.d.cts CHANGED
@@ -79,7 +79,7 @@ declare type AbstractBehaviorEvent =
79
79
  | {
80
80
  type: StrictExtract<AbstractBehaviorEventType, 'decorator.toggle'>
81
81
  decorator: string
82
- offsets?: {
82
+ at?: {
83
83
  anchor: BlockOffset
84
84
  focus: BlockOffset
85
85
  }
@@ -5088,6 +5088,11 @@ declare type ExternalEditorEvent =
5088
5088
  declare type ExtractNamespace<TType extends string> =
5089
5089
  TType extends `${infer Namespace}.${string}` ? Namespace : TType
5090
5090
 
5091
+ declare type FieldDefinition = {
5092
+ name: string
5093
+ type: 'string' | 'number' | 'boolean' | 'array' | 'object'
5094
+ }
5095
+
5091
5096
  /**
5092
5097
  * The editor received focus
5093
5098
  * @beta */
@@ -6113,9 +6118,21 @@ export declare type SchemaDefinition<
6113
6118
  TBaseDefinition extends BaseDefinition = BaseDefinition,
6114
6119
  > = {
6115
6120
  decorators?: ReadonlyArray<TBaseDefinition>
6116
- blockObjects?: ReadonlyArray<TBaseDefinition>
6117
- inlineObjects?: ReadonlyArray<TBaseDefinition>
6118
- annotations?: ReadonlyArray<TBaseDefinition>
6121
+ blockObjects?: ReadonlyArray<
6122
+ TBaseDefinition & {
6123
+ fields?: ReadonlyArray<FieldDefinition>
6124
+ }
6125
+ >
6126
+ inlineObjects?: ReadonlyArray<
6127
+ TBaseDefinition & {
6128
+ fields?: ReadonlyArray<FieldDefinition>
6129
+ }
6130
+ >
6131
+ annotations?: ReadonlyArray<
6132
+ TBaseDefinition & {
6133
+ fields?: ReadonlyArray<FieldDefinition>
6134
+ }
6135
+ >
6119
6136
  lists?: ReadonlyArray<TBaseDefinition>
6120
6137
  styles?: ReadonlyArray<TBaseDefinition>
6121
6138
  }
@@ -6188,7 +6205,7 @@ declare type SyntheticBehaviorEvent =
6188
6205
  | {
6189
6206
  type: StrictExtract<SyntheticBehaviorEventType, 'decorator.add'>
6190
6207
  decorator: string
6191
- offsets?: {
6208
+ at?: {
6192
6209
  anchor: BlockOffset
6193
6210
  focus: BlockOffset
6194
6211
  }
@@ -6199,7 +6216,7 @@ declare type SyntheticBehaviorEvent =
6199
6216
  }
6200
6217
  | {
6201
6218
  type: StrictExtract<SyntheticBehaviorEventType, 'delete'>
6202
- selection: NonNullable<EditorSelection>
6219
+ at: NonNullable<EditorSelection>
6203
6220
  }
6204
6221
  | {
6205
6222
  type: StrictExtract<SyntheticBehaviorEventType, 'delete.backward'>
@@ -6215,8 +6232,10 @@ declare type SyntheticBehaviorEvent =
6215
6232
  }
6216
6233
  | {
6217
6234
  type: StrictExtract<SyntheticBehaviorEventType, 'delete.text'>
6218
- anchor: BlockOffset
6219
- focus: BlockOffset
6235
+ at: {
6236
+ anchor: BlockOffset
6237
+ focus: BlockOffset
6238
+ }
6220
6239
  }
6221
6240
  | {
6222
6241
  type: StrictExtract<SyntheticBehaviorEventType, 'focus'>
@@ -6264,7 +6283,7 @@ declare type SyntheticBehaviorEvent =
6264
6283
  }
6265
6284
  | {
6266
6285
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
6267
- selection: EditorSelection
6286
+ at: EditorSelection
6268
6287
  }
6269
6288
  | {
6270
6289
  type: StrictExtract<SyntheticBehaviorEventType, 'split.block'>
package/lib/index.d.ts CHANGED
@@ -79,7 +79,7 @@ declare type AbstractBehaviorEvent =
79
79
  | {
80
80
  type: StrictExtract<AbstractBehaviorEventType, 'decorator.toggle'>
81
81
  decorator: string
82
- offsets?: {
82
+ at?: {
83
83
  anchor: BlockOffset
84
84
  focus: BlockOffset
85
85
  }
@@ -5088,6 +5088,11 @@ declare type ExternalEditorEvent =
5088
5088
  declare type ExtractNamespace<TType extends string> =
5089
5089
  TType extends `${infer Namespace}.${string}` ? Namespace : TType
5090
5090
 
5091
+ declare type FieldDefinition = {
5092
+ name: string
5093
+ type: 'string' | 'number' | 'boolean' | 'array' | 'object'
5094
+ }
5095
+
5091
5096
  /**
5092
5097
  * The editor received focus
5093
5098
  * @beta */
@@ -6113,9 +6118,21 @@ export declare type SchemaDefinition<
6113
6118
  TBaseDefinition extends BaseDefinition = BaseDefinition,
6114
6119
  > = {
6115
6120
  decorators?: ReadonlyArray<TBaseDefinition>
6116
- blockObjects?: ReadonlyArray<TBaseDefinition>
6117
- inlineObjects?: ReadonlyArray<TBaseDefinition>
6118
- annotations?: ReadonlyArray<TBaseDefinition>
6121
+ blockObjects?: ReadonlyArray<
6122
+ TBaseDefinition & {
6123
+ fields?: ReadonlyArray<FieldDefinition>
6124
+ }
6125
+ >
6126
+ inlineObjects?: ReadonlyArray<
6127
+ TBaseDefinition & {
6128
+ fields?: ReadonlyArray<FieldDefinition>
6129
+ }
6130
+ >
6131
+ annotations?: ReadonlyArray<
6132
+ TBaseDefinition & {
6133
+ fields?: ReadonlyArray<FieldDefinition>
6134
+ }
6135
+ >
6119
6136
  lists?: ReadonlyArray<TBaseDefinition>
6120
6137
  styles?: ReadonlyArray<TBaseDefinition>
6121
6138
  }
@@ -6188,7 +6205,7 @@ declare type SyntheticBehaviorEvent =
6188
6205
  | {
6189
6206
  type: StrictExtract<SyntheticBehaviorEventType, 'decorator.add'>
6190
6207
  decorator: string
6191
- offsets?: {
6208
+ at?: {
6192
6209
  anchor: BlockOffset
6193
6210
  focus: BlockOffset
6194
6211
  }
@@ -6199,7 +6216,7 @@ declare type SyntheticBehaviorEvent =
6199
6216
  }
6200
6217
  | {
6201
6218
  type: StrictExtract<SyntheticBehaviorEventType, 'delete'>
6202
- selection: NonNullable<EditorSelection>
6219
+ at: NonNullable<EditorSelection>
6203
6220
  }
6204
6221
  | {
6205
6222
  type: StrictExtract<SyntheticBehaviorEventType, 'delete.backward'>
@@ -6215,8 +6232,10 @@ declare type SyntheticBehaviorEvent =
6215
6232
  }
6216
6233
  | {
6217
6234
  type: StrictExtract<SyntheticBehaviorEventType, 'delete.text'>
6218
- anchor: BlockOffset
6219
- focus: BlockOffset
6235
+ at: {
6236
+ anchor: BlockOffset
6237
+ focus: BlockOffset
6238
+ }
6220
6239
  }
6221
6240
  | {
6222
6241
  type: StrictExtract<SyntheticBehaviorEventType, 'focus'>
@@ -6264,7 +6283,7 @@ declare type SyntheticBehaviorEvent =
6264
6283
  }
6265
6284
  | {
6266
6285
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
6267
- selection: EditorSelection
6286
+ at: EditorSelection
6268
6287
  }
6269
6288
  | {
6270
6289
  type: StrictExtract<SyntheticBehaviorEventType, 'split.block'>
package/lib/index.js CHANGED
@@ -1443,7 +1443,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
1443
1443
  type: "behavior event",
1444
1444
  behaviorEvent: {
1445
1445
  type: "select",
1446
- selection: isSelectionCollapsed$1(dragSelection) ? dragSelection : {
1446
+ at: isSelectionCollapsed$1(dragSelection) ? dragSelection : {
1447
1447
  anchor: getSelectionEndPoint(dragSelection),
1448
1448
  focus: getSelectionEndPoint(dragSelection),
1449
1449
  backward: !1