@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.
- package/README.md +228 -261
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selection-collapsed.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
- package/lib/_chunks-es/selector.is-selection-collapsed.js.map +1 -1
- package/lib/behaviors/index.cjs +4 -1
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.d.cts +23 -23
- package/lib/behaviors/index.d.ts +23 -23
- package/lib/behaviors/index.js +4 -1
- package/lib/behaviors/index.js.map +1 -1
- package/lib/index.cjs +78 -69
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +123 -753
- package/lib/index.d.ts +123 -753
- package/lib/index.js +78 -69
- package/lib/index.js.map +1 -1
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +30 -30
- package/lib/selectors/index.d.ts +30 -30
- package/lib/selectors/index.js.map +1 -1
- package/package.json +8 -8
- package/src/behaviors/behavior.code-editor.ts +2 -2
- package/src/behaviors/behavior.core.ts +2 -2
- package/src/behaviors/behavior.emoji-picker.ts +8 -3
- package/src/behaviors/behavior.links.ts +2 -2
- package/src/behaviors/behavior.markdown.ts +2 -2
- package/src/behaviors/behavior.types.ts +10 -10
- package/src/editor/PortableTextEditor.tsx +2 -0
- package/src/editor/__tests__/self-solving.test.tsx +14 -0
- package/src/editor/components/Synchronizer.tsx +6 -1
- package/src/editor/create-editor.ts +14 -3
- package/src/editor/define-schema.ts +4 -4
- package/src/editor/editor-event-listener.tsx +1 -1
- package/src/editor/editor-machine.ts +42 -52
- package/src/editor/editor-provider.tsx +3 -3
- package/src/editor/editor-selector.ts +31 -14
- package/src/editor/editor-snapshot.ts +2 -2
- package/src/editor/get-value.ts +12 -5
- package/src/editor/hooks/usePortableTextEditor.ts +1 -0
- package/src/editor/hooks/usePortableTextEditorSelection.tsx +1 -0
- package/src/selectors/selector.get-active-list-item.ts +1 -1
- package/src/selectors/selector.get-active-style.ts +1 -1
- package/src/selectors/selector.get-selected-spans.ts +1 -1
- package/src/selectors/selector.get-selection-text.ts +1 -1
- package/src/selectors/selector.get-text-before.ts +1 -1
- package/src/selectors/selector.is-active-annotation.ts +1 -1
- package/src/selectors/selector.is-active-decorator.ts +1 -1
- package/src/selectors/selector.is-active-list-item.ts +1 -1
- package/src/selectors/selector.is-active-style.ts +1 -1
- package/src/selectors/selector.is-selection-collapsed.ts +1 -1
- package/src/selectors/selector.is-selection-expanded.ts +1 -1
- package/src/selectors/selectors.ts +13 -13
- 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
|
-
* @
|
|
8
|
+
* @public
|
|
9
9
|
*/
|
|
10
10
|
export const getBlockTextBefore: EditorSelector<string> = ({context}) => {
|
|
11
11
|
if (!context.selection) {
|
|
@@ -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
|
-
* @
|
|
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
|
-
* @
|
|
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 {isSelectionCollapsed} from './selector.is-selection-collapsed'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
287
|
+
* @public
|
|
288
288
|
*/
|
|
289
289
|
export const getNextBlock: EditorSelector<
|
|
290
290
|
{node: PortableTextBlock; path: [KeyedSegment]} | undefined
|
package/src/types/editor.ts
CHANGED
|
@@ -113,9 +113,9 @@ export interface History {
|
|
|
113
113
|
undos: HistoryItem[]
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
/** @
|
|
116
|
+
/** @public */
|
|
117
117
|
export type EditorSelectionPoint = {path: Path; offset: number}
|
|
118
|
-
/** @
|
|
118
|
+
/** @public */
|
|
119
119
|
export type EditorSelection = {
|
|
120
120
|
anchor: EditorSelectionPoint
|
|
121
121
|
focus: EditorSelectionPoint
|