@portabletext/editor 1.17.1 → 1.18.0

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 (56) hide show
  1. package/README.md +228 -261
  2. package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
  3. package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
  4. package/lib/_chunks-cjs/selector.is-selection-collapsed.cjs.map +1 -1
  5. package/lib/_chunks-es/behavior.core.js.map +1 -1
  6. package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
  7. package/lib/_chunks-es/selector.is-selection-collapsed.js.map +1 -1
  8. package/lib/behaviors/index.cjs +4 -1
  9. package/lib/behaviors/index.cjs.map +1 -1
  10. package/lib/behaviors/index.d.cts +23 -23
  11. package/lib/behaviors/index.d.ts +23 -23
  12. package/lib/behaviors/index.js +4 -1
  13. package/lib/behaviors/index.js.map +1 -1
  14. package/lib/index.cjs +78 -69
  15. package/lib/index.cjs.map +1 -1
  16. package/lib/index.d.cts +123 -753
  17. package/lib/index.d.ts +123 -753
  18. package/lib/index.js +78 -69
  19. package/lib/index.js.map +1 -1
  20. package/lib/selectors/index.cjs.map +1 -1
  21. package/lib/selectors/index.d.cts +30 -30
  22. package/lib/selectors/index.d.ts +30 -30
  23. package/lib/selectors/index.js.map +1 -1
  24. package/package.json +8 -8
  25. package/src/behaviors/behavior.code-editor.ts +2 -2
  26. package/src/behaviors/behavior.core.ts +2 -2
  27. package/src/behaviors/behavior.emoji-picker.ts +8 -3
  28. package/src/behaviors/behavior.links.ts +2 -2
  29. package/src/behaviors/behavior.markdown.ts +2 -2
  30. package/src/behaviors/behavior.types.ts +10 -10
  31. package/src/editor/PortableTextEditor.tsx +2 -0
  32. package/src/editor/__tests__/self-solving.test.tsx +14 -0
  33. package/src/editor/components/Synchronizer.tsx +6 -1
  34. package/src/editor/create-editor.ts +14 -3
  35. package/src/editor/define-schema.ts +4 -4
  36. package/src/editor/editor-event-listener.tsx +1 -1
  37. package/src/editor/editor-machine.ts +42 -52
  38. package/src/editor/editor-provider.tsx +3 -3
  39. package/src/editor/editor-selector.ts +31 -14
  40. package/src/editor/editor-snapshot.ts +2 -2
  41. package/src/editor/get-value.ts +12 -5
  42. package/src/editor/hooks/usePortableTextEditor.ts +1 -0
  43. package/src/editor/hooks/usePortableTextEditorSelection.tsx +1 -0
  44. package/src/selectors/selector.get-active-list-item.ts +1 -1
  45. package/src/selectors/selector.get-active-style.ts +1 -1
  46. package/src/selectors/selector.get-selected-spans.ts +1 -1
  47. package/src/selectors/selector.get-selection-text.ts +1 -1
  48. package/src/selectors/selector.get-text-before.ts +1 -1
  49. package/src/selectors/selector.is-active-annotation.ts +1 -1
  50. package/src/selectors/selector.is-active-decorator.ts +1 -1
  51. package/src/selectors/selector.is-active-list-item.ts +1 -1
  52. package/src/selectors/selector.is-active-style.ts +1 -1
  53. package/src/selectors/selector.is-selection-collapsed.ts +1 -1
  54. package/src/selectors/selector.is-selection-expanded.ts +1 -1
  55. package/src/selectors/selectors.ts +13 -13
  56. package/src/types/editor.ts +2 -2
@@ -5,7 +5,7 @@ import {reverseSelection} from '../editor/utils/utils.reverse-selection'
5
5
  import {getSelectionText} from './selector.get-selection-text'
6
6
 
7
7
  /**
8
- * @alpha
8
+ * @public
9
9
  */
10
10
  export const getBlockTextBefore: EditorSelector<string> = ({context}) => {
11
11
  if (!context.selection) {
@@ -4,7 +4,7 @@ import {getSelectedSpans} from './selector.get-selected-spans'
4
4
  import {getSelectedBlocks} from './selectors'
5
5
 
6
6
  /**
7
- * @alpha
7
+ * @public
8
8
  */
9
9
  export function isActiveAnnotation(
10
10
  annotation: string,
@@ -3,7 +3,7 @@ import {getSelectedSpans} from './selector.get-selected-spans'
3
3
  import {isSelectionExpanded} from './selector.is-selection-expanded'
4
4
 
5
5
  /**
6
- * @alpha
6
+ * @public
7
7
  */
8
8
  export function isActiveDecorator(decorator: string): EditorSelector<boolean> {
9
9
  return (snapshot) => {
@@ -2,7 +2,7 @@ import type {EditorSelector} from '../editor/editor-selector'
2
2
  import {getActiveListItem} from './selector.get-active-list-item'
3
3
 
4
4
  /**
5
- * @alpha
5
+ * @public
6
6
  */
7
7
  export function isActiveListItem(listItem: string): EditorSelector<boolean> {
8
8
  return (snapshot) => {
@@ -2,7 +2,7 @@ import type {EditorSelector} from '../editor/editor-selector'
2
2
  import {getActiveStyle} from './selector.get-active-style'
3
3
 
4
4
  /**
5
- * @alpha
5
+ * @public
6
6
  */
7
7
  export function isActiveStyle(style: string): EditorSelector<boolean> {
8
8
  return (snapshot) => {
@@ -1,7 +1,7 @@
1
1
  import type {EditorSelector} from '../editor/editor-selector'
2
2
 
3
3
  /**
4
- * @alpha
4
+ * @public
5
5
  */
6
6
  export const isSelectionCollapsed: EditorSelector<boolean> = ({context}) => {
7
7
  return (
@@ -2,7 +2,7 @@ import type {EditorSelector} from '../editor/editor-selector'
2
2
  import {isSelectionCollapsed} from './selector.is-selection-collapsed'
3
3
 
4
4
  /**
5
- * @alpha
5
+ * @public
6
6
  */
7
7
  export const isSelectionExpanded: EditorSelector<boolean> = ({context}) => {
8
8
  return !isSelectionCollapsed({context})
@@ -13,7 +13,7 @@ import {createGuards} from '../behavior-actions/behavior.guards'
13
13
  import type {EditorSelector} from '../editor/editor-selector'
14
14
 
15
15
  /**
16
- * @alpha
16
+ * @public
17
17
  */
18
18
  export const getFocusBlock: EditorSelector<
19
19
  {node: PortableTextBlock; path: [KeyedSegment]} | undefined
@@ -32,7 +32,7 @@ export const getFocusBlock: EditorSelector<
32
32
  }
33
33
 
34
34
  /**
35
- * @alpha
35
+ * @public
36
36
  */
37
37
  export const getFocusListBlock: EditorSelector<
38
38
  {node: PortableTextListBlock; path: [KeyedSegment]} | undefined
@@ -46,7 +46,7 @@ export const getFocusListBlock: EditorSelector<
46
46
  }
47
47
 
48
48
  /**
49
- * @alpha
49
+ * @public
50
50
  */
51
51
  export const getFocusTextBlock: EditorSelector<
52
52
  {node: PortableTextTextBlock; path: [KeyedSegment]} | undefined
@@ -59,7 +59,7 @@ export const getFocusTextBlock: EditorSelector<
59
59
  }
60
60
 
61
61
  /**
62
- * @alpha
62
+ * @public
63
63
  */
64
64
  export const getFocusBlockObject: EditorSelector<
65
65
  {node: PortableTextObject; path: [KeyedSegment]} | undefined
@@ -72,7 +72,7 @@ export const getFocusBlockObject: EditorSelector<
72
72
  }
73
73
 
74
74
  /**
75
- * @alpha
75
+ * @public
76
76
  */
77
77
  export const getFocusChild: EditorSelector<
78
78
  | {
@@ -103,7 +103,7 @@ export const getFocusChild: EditorSelector<
103
103
  }
104
104
 
105
105
  /**
106
- * @alpha
106
+ * @public
107
107
  */
108
108
  export const getFocusSpan: EditorSelector<
109
109
  | {node: PortableTextSpan; path: [KeyedSegment, 'children', KeyedSegment]}
@@ -117,7 +117,7 @@ export const getFocusSpan: EditorSelector<
117
117
  }
118
118
 
119
119
  /**
120
- * @alpha
120
+ * @public
121
121
  */
122
122
  export const getFirstBlock: EditorSelector<
123
123
  {node: PortableTextBlock; path: [KeyedSegment]} | undefined
@@ -128,7 +128,7 @@ export const getFirstBlock: EditorSelector<
128
128
  }
129
129
 
130
130
  /**
131
- * @alpha
131
+ * @public
132
132
  */
133
133
  export const getLastBlock: EditorSelector<
134
134
  {node: PortableTextBlock; path: [KeyedSegment]} | undefined
@@ -141,7 +141,7 @@ export const getLastBlock: EditorSelector<
141
141
  }
142
142
 
143
143
  /**
144
- * @alpha
144
+ * @public
145
145
  */
146
146
  export const getSelectedBlocks: EditorSelector<
147
147
  Array<{node: PortableTextBlock; path: [KeyedSegment]}>
@@ -195,7 +195,7 @@ export const getSelectedBlocks: EditorSelector<
195
195
  }
196
196
 
197
197
  /**
198
- * @alpha
198
+ * @public
199
199
  */
200
200
  export const getSelectionStartBlock: EditorSelector<
201
201
  | {
@@ -224,7 +224,7 @@ export const getSelectionStartBlock: EditorSelector<
224
224
  }
225
225
 
226
226
  /**
227
- * @alpha
227
+ * @public
228
228
  */
229
229
  export const getSelectionEndBlock: EditorSelector<
230
230
  | {
@@ -253,7 +253,7 @@ export const getSelectionEndBlock: EditorSelector<
253
253
  }
254
254
 
255
255
  /**
256
- * @alpha
256
+ * @public
257
257
  */
258
258
  export const getPreviousBlock: EditorSelector<
259
259
  {node: PortableTextBlock; path: [KeyedSegment]} | undefined
@@ -284,7 +284,7 @@ export const getPreviousBlock: EditorSelector<
284
284
  }
285
285
 
286
286
  /**
287
- * @alpha
287
+ * @public
288
288
  */
289
289
  export const getNextBlock: EditorSelector<
290
290
  {node: PortableTextBlock; path: [KeyedSegment]} | undefined
@@ -113,9 +113,9 @@ export interface History {
113
113
  undos: HistoryItem[]
114
114
  }
115
115
 
116
- /** @beta */
116
+ /** @public */
117
117
  export type EditorSelectionPoint = {path: Path; offset: number}
118
- /** @beta */
118
+ /** @public */
119
119
  export type EditorSelection = {
120
120
  anchor: EditorSelectionPoint
121
121
  focus: EditorSelectionPoint