@portabletext/editor 1.30.1 → 1.30.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.
- package/lib/_chunks-cjs/behavior.core.cjs +1 -11
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/plugin.event-listener.cjs +98 -72
- package/lib/_chunks-cjs/plugin.event-listener.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js +1 -11
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/plugin.event-listener.js +100 -74
- package/lib/_chunks-es/plugin.event-listener.js.map +1 -1
- package/lib/behaviors/index.cjs +0 -1
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.d.cts +0 -3016
- package/lib/behaviors/index.d.ts +0 -3016
- package/lib/behaviors/index.js +1 -2
- package/lib/index.d.cts +111 -1
- package/lib/index.d.ts +111 -1
- package/lib/plugins/index.d.cts +111 -1
- package/lib/plugins/index.d.ts +111 -1
- package/package.json +6 -6
- package/src/behaviors/behavior.core.ts +0 -14
- package/src/behaviors/behavior.foundational.ts +15 -0
- package/src/behaviors/index.ts +1 -1
- package/src/editor/editor-machine.ts +6 -2
- package/src/editor/plugins/create-with-event-listeners.ts +8 -2
- package/src/internal-utils/key-is.ts +10 -0
package/lib/behaviors/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineBehavior, isHotkey } from "../_chunks-es/behavior.core.js";
|
|
2
|
-
import {
|
|
2
|
+
import { coreBehaviors, raise } from "../_chunks-es/behavior.core.js";
|
|
3
3
|
import { getFirstBlock, getSelectedBlocks, getLastBlock, getFocusTextBlock, isSelectionCollapsed, getFocusSpan } from "../_chunks-es/selector.is-at-the-start-of-block.js";
|
|
4
4
|
import { createActor, setup, assign, assertEvent } from "xstate";
|
|
5
5
|
import { getBlockTextBefore } from "../_chunks-es/selector.get-text-before.js";
|
|
@@ -421,7 +421,6 @@ function createLinkBehaviors(config) {
|
|
|
421
421
|
return [pasteLinkOnSelection, pasteLinkAtCaret];
|
|
422
422
|
}
|
|
423
423
|
export {
|
|
424
|
-
coreBehavior,
|
|
425
424
|
coreBehaviors,
|
|
426
425
|
createCodeEditorBehaviors,
|
|
427
426
|
createEmojiPickerBehaviors,
|
package/lib/index.d.cts
CHANGED
|
@@ -65,10 +65,12 @@ import {
|
|
|
65
65
|
} from 'xstate'
|
|
66
66
|
import {GuardArgs} from 'xstate/guards'
|
|
67
67
|
import {
|
|
68
|
+
BehaviorEvent as BehaviorEvent_2,
|
|
68
69
|
BlockOffset as BlockOffset_2,
|
|
69
70
|
PortableTextMemberSchemaTypes as PortableTextMemberSchemaTypes_2,
|
|
70
71
|
} from '..'
|
|
71
72
|
import {MIMEType as MIMEType_2} from '../internal-utils/mime-type'
|
|
73
|
+
import {PickFromUnion as PickFromUnion_2} from '../type-utils'
|
|
72
74
|
|
|
73
75
|
/**
|
|
74
76
|
* @public
|
|
@@ -2109,7 +2111,115 @@ declare const editorMachine: StateMachine<
|
|
|
2109
2111
|
AnyEventObject
|
|
2110
2112
|
>
|
|
2111
2113
|
}) => {
|
|
2112
|
-
behaviors: Set<
|
|
2114
|
+
behaviors: Set<
|
|
2115
|
+
Behavior<
|
|
2116
|
+
| 'focus'
|
|
2117
|
+
| 'delete'
|
|
2118
|
+
| 'select'
|
|
2119
|
+
| 'serialize'
|
|
2120
|
+
| 'copy'
|
|
2121
|
+
| 'serialization.failure'
|
|
2122
|
+
| 'serialization.success'
|
|
2123
|
+
| 'deserialize'
|
|
2124
|
+
| 'deserialization.failure'
|
|
2125
|
+
| 'deserialization.success'
|
|
2126
|
+
| 'annotation.add'
|
|
2127
|
+
| 'annotation.remove'
|
|
2128
|
+
| 'annotation.toggle'
|
|
2129
|
+
| 'block.set'
|
|
2130
|
+
| 'block.unset'
|
|
2131
|
+
| 'blur'
|
|
2132
|
+
| 'data transfer.set'
|
|
2133
|
+
| 'decorator.add'
|
|
2134
|
+
| 'decorator.remove'
|
|
2135
|
+
| 'decorator.toggle'
|
|
2136
|
+
| 'delete.backward'
|
|
2137
|
+
| 'delete.block'
|
|
2138
|
+
| 'delete.forward'
|
|
2139
|
+
| 'delete.text'
|
|
2140
|
+
| 'insert.blocks'
|
|
2141
|
+
| 'insert.block object'
|
|
2142
|
+
| 'insert.inline object'
|
|
2143
|
+
| 'insert.break'
|
|
2144
|
+
| 'insert.soft break'
|
|
2145
|
+
| 'insert.block'
|
|
2146
|
+
| 'insert.span'
|
|
2147
|
+
| 'insert.text'
|
|
2148
|
+
| 'insert.text block'
|
|
2149
|
+
| 'list item.add'
|
|
2150
|
+
| 'list item.remove'
|
|
2151
|
+
| 'list item.toggle'
|
|
2152
|
+
| 'move.block'
|
|
2153
|
+
| 'move.block down'
|
|
2154
|
+
| 'move.block up'
|
|
2155
|
+
| 'select.previous block'
|
|
2156
|
+
| 'select.next block'
|
|
2157
|
+
| 'style.add'
|
|
2158
|
+
| 'style.remove'
|
|
2159
|
+
| 'style.toggle'
|
|
2160
|
+
| 'text block.set'
|
|
2161
|
+
| 'text block.unset'
|
|
2162
|
+
| 'key.down'
|
|
2163
|
+
| 'key.up'
|
|
2164
|
+
| 'paste'
|
|
2165
|
+
| `custom.${string}`,
|
|
2166
|
+
true,
|
|
2167
|
+
PickFromUnion_2<
|
|
2168
|
+
BehaviorEvent_2,
|
|
2169
|
+
'type',
|
|
2170
|
+
| 'focus'
|
|
2171
|
+
| 'delete'
|
|
2172
|
+
| 'select'
|
|
2173
|
+
| 'serialize'
|
|
2174
|
+
| 'copy'
|
|
2175
|
+
| 'serialization.failure'
|
|
2176
|
+
| 'serialization.success'
|
|
2177
|
+
| 'deserialize'
|
|
2178
|
+
| 'deserialization.failure'
|
|
2179
|
+
| 'deserialization.success'
|
|
2180
|
+
| 'annotation.add'
|
|
2181
|
+
| 'annotation.remove'
|
|
2182
|
+
| 'annotation.toggle'
|
|
2183
|
+
| 'block.set'
|
|
2184
|
+
| 'block.unset'
|
|
2185
|
+
| 'blur'
|
|
2186
|
+
| 'data transfer.set'
|
|
2187
|
+
| 'decorator.add'
|
|
2188
|
+
| 'decorator.remove'
|
|
2189
|
+
| 'decorator.toggle'
|
|
2190
|
+
| 'delete.backward'
|
|
2191
|
+
| 'delete.block'
|
|
2192
|
+
| 'delete.forward'
|
|
2193
|
+
| 'delete.text'
|
|
2194
|
+
| 'insert.blocks'
|
|
2195
|
+
| 'insert.block object'
|
|
2196
|
+
| 'insert.inline object'
|
|
2197
|
+
| 'insert.break'
|
|
2198
|
+
| 'insert.soft break'
|
|
2199
|
+
| 'insert.block'
|
|
2200
|
+
| 'insert.span'
|
|
2201
|
+
| 'insert.text'
|
|
2202
|
+
| 'insert.text block'
|
|
2203
|
+
| 'list item.add'
|
|
2204
|
+
| 'list item.remove'
|
|
2205
|
+
| 'list item.toggle'
|
|
2206
|
+
| 'move.block'
|
|
2207
|
+
| 'move.block down'
|
|
2208
|
+
| 'move.block up'
|
|
2209
|
+
| 'select.previous block'
|
|
2210
|
+
| 'select.next block'
|
|
2211
|
+
| 'style.add'
|
|
2212
|
+
| 'style.remove'
|
|
2213
|
+
| 'style.toggle'
|
|
2214
|
+
| 'text block.set'
|
|
2215
|
+
| 'text block.unset'
|
|
2216
|
+
| 'key.down'
|
|
2217
|
+
| 'key.up'
|
|
2218
|
+
| 'paste'
|
|
2219
|
+
| `custom.${string}`
|
|
2220
|
+
>
|
|
2221
|
+
>
|
|
2222
|
+
>
|
|
2113
2223
|
converters: Set<Converter>
|
|
2114
2224
|
keyGenerator: () => string
|
|
2115
2225
|
pendingEvents: never[]
|
package/lib/index.d.ts
CHANGED
|
@@ -65,10 +65,12 @@ import {
|
|
|
65
65
|
} from 'xstate'
|
|
66
66
|
import {GuardArgs} from 'xstate/guards'
|
|
67
67
|
import {
|
|
68
|
+
BehaviorEvent as BehaviorEvent_2,
|
|
68
69
|
BlockOffset as BlockOffset_2,
|
|
69
70
|
PortableTextMemberSchemaTypes as PortableTextMemberSchemaTypes_2,
|
|
70
71
|
} from '..'
|
|
71
72
|
import {MIMEType as MIMEType_2} from '../internal-utils/mime-type'
|
|
73
|
+
import {PickFromUnion as PickFromUnion_2} from '../type-utils'
|
|
72
74
|
|
|
73
75
|
/**
|
|
74
76
|
* @public
|
|
@@ -2109,7 +2111,115 @@ declare const editorMachine: StateMachine<
|
|
|
2109
2111
|
AnyEventObject
|
|
2110
2112
|
>
|
|
2111
2113
|
}) => {
|
|
2112
|
-
behaviors: Set<
|
|
2114
|
+
behaviors: Set<
|
|
2115
|
+
Behavior<
|
|
2116
|
+
| 'focus'
|
|
2117
|
+
| 'delete'
|
|
2118
|
+
| 'select'
|
|
2119
|
+
| 'serialize'
|
|
2120
|
+
| 'copy'
|
|
2121
|
+
| 'serialization.failure'
|
|
2122
|
+
| 'serialization.success'
|
|
2123
|
+
| 'deserialize'
|
|
2124
|
+
| 'deserialization.failure'
|
|
2125
|
+
| 'deserialization.success'
|
|
2126
|
+
| 'annotation.add'
|
|
2127
|
+
| 'annotation.remove'
|
|
2128
|
+
| 'annotation.toggle'
|
|
2129
|
+
| 'block.set'
|
|
2130
|
+
| 'block.unset'
|
|
2131
|
+
| 'blur'
|
|
2132
|
+
| 'data transfer.set'
|
|
2133
|
+
| 'decorator.add'
|
|
2134
|
+
| 'decorator.remove'
|
|
2135
|
+
| 'decorator.toggle'
|
|
2136
|
+
| 'delete.backward'
|
|
2137
|
+
| 'delete.block'
|
|
2138
|
+
| 'delete.forward'
|
|
2139
|
+
| 'delete.text'
|
|
2140
|
+
| 'insert.blocks'
|
|
2141
|
+
| 'insert.block object'
|
|
2142
|
+
| 'insert.inline object'
|
|
2143
|
+
| 'insert.break'
|
|
2144
|
+
| 'insert.soft break'
|
|
2145
|
+
| 'insert.block'
|
|
2146
|
+
| 'insert.span'
|
|
2147
|
+
| 'insert.text'
|
|
2148
|
+
| 'insert.text block'
|
|
2149
|
+
| 'list item.add'
|
|
2150
|
+
| 'list item.remove'
|
|
2151
|
+
| 'list item.toggle'
|
|
2152
|
+
| 'move.block'
|
|
2153
|
+
| 'move.block down'
|
|
2154
|
+
| 'move.block up'
|
|
2155
|
+
| 'select.previous block'
|
|
2156
|
+
| 'select.next block'
|
|
2157
|
+
| 'style.add'
|
|
2158
|
+
| 'style.remove'
|
|
2159
|
+
| 'style.toggle'
|
|
2160
|
+
| 'text block.set'
|
|
2161
|
+
| 'text block.unset'
|
|
2162
|
+
| 'key.down'
|
|
2163
|
+
| 'key.up'
|
|
2164
|
+
| 'paste'
|
|
2165
|
+
| `custom.${string}`,
|
|
2166
|
+
true,
|
|
2167
|
+
PickFromUnion_2<
|
|
2168
|
+
BehaviorEvent_2,
|
|
2169
|
+
'type',
|
|
2170
|
+
| 'focus'
|
|
2171
|
+
| 'delete'
|
|
2172
|
+
| 'select'
|
|
2173
|
+
| 'serialize'
|
|
2174
|
+
| 'copy'
|
|
2175
|
+
| 'serialization.failure'
|
|
2176
|
+
| 'serialization.success'
|
|
2177
|
+
| 'deserialize'
|
|
2178
|
+
| 'deserialization.failure'
|
|
2179
|
+
| 'deserialization.success'
|
|
2180
|
+
| 'annotation.add'
|
|
2181
|
+
| 'annotation.remove'
|
|
2182
|
+
| 'annotation.toggle'
|
|
2183
|
+
| 'block.set'
|
|
2184
|
+
| 'block.unset'
|
|
2185
|
+
| 'blur'
|
|
2186
|
+
| 'data transfer.set'
|
|
2187
|
+
| 'decorator.add'
|
|
2188
|
+
| 'decorator.remove'
|
|
2189
|
+
| 'decorator.toggle'
|
|
2190
|
+
| 'delete.backward'
|
|
2191
|
+
| 'delete.block'
|
|
2192
|
+
| 'delete.forward'
|
|
2193
|
+
| 'delete.text'
|
|
2194
|
+
| 'insert.blocks'
|
|
2195
|
+
| 'insert.block object'
|
|
2196
|
+
| 'insert.inline object'
|
|
2197
|
+
| 'insert.break'
|
|
2198
|
+
| 'insert.soft break'
|
|
2199
|
+
| 'insert.block'
|
|
2200
|
+
| 'insert.span'
|
|
2201
|
+
| 'insert.text'
|
|
2202
|
+
| 'insert.text block'
|
|
2203
|
+
| 'list item.add'
|
|
2204
|
+
| 'list item.remove'
|
|
2205
|
+
| 'list item.toggle'
|
|
2206
|
+
| 'move.block'
|
|
2207
|
+
| 'move.block down'
|
|
2208
|
+
| 'move.block up'
|
|
2209
|
+
| 'select.previous block'
|
|
2210
|
+
| 'select.next block'
|
|
2211
|
+
| 'style.add'
|
|
2212
|
+
| 'style.remove'
|
|
2213
|
+
| 'style.toggle'
|
|
2214
|
+
| 'text block.set'
|
|
2215
|
+
| 'text block.unset'
|
|
2216
|
+
| 'key.down'
|
|
2217
|
+
| 'key.up'
|
|
2218
|
+
| 'paste'
|
|
2219
|
+
| `custom.${string}`
|
|
2220
|
+
>
|
|
2221
|
+
>
|
|
2222
|
+
>
|
|
2113
2223
|
converters: Set<Converter>
|
|
2114
2224
|
keyGenerator: () => string
|
|
2115
2225
|
pendingEvents: never[]
|
package/lib/plugins/index.d.cts
CHANGED
|
@@ -46,10 +46,12 @@ import {
|
|
|
46
46
|
} from 'xstate'
|
|
47
47
|
import {GuardArgs} from 'xstate/guards'
|
|
48
48
|
import {
|
|
49
|
+
BehaviorEvent as BehaviorEvent_2,
|
|
49
50
|
BlockOffset as BlockOffset_2,
|
|
50
51
|
PortableTextMemberSchemaTypes as PortableTextMemberSchemaTypes_2,
|
|
51
52
|
} from '..'
|
|
52
53
|
import {MIMEType as MIMEType_2} from '../internal-utils/mime-type'
|
|
54
|
+
import {PickFromUnion as PickFromUnion_2} from '../type-utils'
|
|
53
55
|
|
|
54
56
|
/**
|
|
55
57
|
* @beta
|
|
@@ -1842,7 +1844,115 @@ declare const editorMachine: StateMachine<
|
|
|
1842
1844
|
AnyEventObject
|
|
1843
1845
|
>
|
|
1844
1846
|
}) => {
|
|
1845
|
-
behaviors: Set<
|
|
1847
|
+
behaviors: Set<
|
|
1848
|
+
Behavior<
|
|
1849
|
+
| 'focus'
|
|
1850
|
+
| 'delete'
|
|
1851
|
+
| 'select'
|
|
1852
|
+
| 'serialize'
|
|
1853
|
+
| 'copy'
|
|
1854
|
+
| 'serialization.failure'
|
|
1855
|
+
| 'serialization.success'
|
|
1856
|
+
| 'deserialize'
|
|
1857
|
+
| 'deserialization.failure'
|
|
1858
|
+
| 'deserialization.success'
|
|
1859
|
+
| 'annotation.add'
|
|
1860
|
+
| 'annotation.remove'
|
|
1861
|
+
| 'annotation.toggle'
|
|
1862
|
+
| 'block.set'
|
|
1863
|
+
| 'block.unset'
|
|
1864
|
+
| 'blur'
|
|
1865
|
+
| 'data transfer.set'
|
|
1866
|
+
| 'decorator.add'
|
|
1867
|
+
| 'decorator.remove'
|
|
1868
|
+
| 'decorator.toggle'
|
|
1869
|
+
| 'delete.backward'
|
|
1870
|
+
| 'delete.block'
|
|
1871
|
+
| 'delete.forward'
|
|
1872
|
+
| 'delete.text'
|
|
1873
|
+
| 'insert.blocks'
|
|
1874
|
+
| 'insert.block object'
|
|
1875
|
+
| 'insert.inline object'
|
|
1876
|
+
| 'insert.break'
|
|
1877
|
+
| 'insert.soft break'
|
|
1878
|
+
| 'insert.block'
|
|
1879
|
+
| 'insert.span'
|
|
1880
|
+
| 'insert.text'
|
|
1881
|
+
| 'insert.text block'
|
|
1882
|
+
| 'list item.add'
|
|
1883
|
+
| 'list item.remove'
|
|
1884
|
+
| 'list item.toggle'
|
|
1885
|
+
| 'move.block'
|
|
1886
|
+
| 'move.block down'
|
|
1887
|
+
| 'move.block up'
|
|
1888
|
+
| 'select.previous block'
|
|
1889
|
+
| 'select.next block'
|
|
1890
|
+
| 'style.add'
|
|
1891
|
+
| 'style.remove'
|
|
1892
|
+
| 'style.toggle'
|
|
1893
|
+
| 'text block.set'
|
|
1894
|
+
| 'text block.unset'
|
|
1895
|
+
| 'key.down'
|
|
1896
|
+
| 'key.up'
|
|
1897
|
+
| 'paste'
|
|
1898
|
+
| `custom.${string}`,
|
|
1899
|
+
true,
|
|
1900
|
+
PickFromUnion_2<
|
|
1901
|
+
BehaviorEvent_2,
|
|
1902
|
+
'type',
|
|
1903
|
+
| 'focus'
|
|
1904
|
+
| 'delete'
|
|
1905
|
+
| 'select'
|
|
1906
|
+
| 'serialize'
|
|
1907
|
+
| 'copy'
|
|
1908
|
+
| 'serialization.failure'
|
|
1909
|
+
| 'serialization.success'
|
|
1910
|
+
| 'deserialize'
|
|
1911
|
+
| 'deserialization.failure'
|
|
1912
|
+
| 'deserialization.success'
|
|
1913
|
+
| 'annotation.add'
|
|
1914
|
+
| 'annotation.remove'
|
|
1915
|
+
| 'annotation.toggle'
|
|
1916
|
+
| 'block.set'
|
|
1917
|
+
| 'block.unset'
|
|
1918
|
+
| 'blur'
|
|
1919
|
+
| 'data transfer.set'
|
|
1920
|
+
| 'decorator.add'
|
|
1921
|
+
| 'decorator.remove'
|
|
1922
|
+
| 'decorator.toggle'
|
|
1923
|
+
| 'delete.backward'
|
|
1924
|
+
| 'delete.block'
|
|
1925
|
+
| 'delete.forward'
|
|
1926
|
+
| 'delete.text'
|
|
1927
|
+
| 'insert.blocks'
|
|
1928
|
+
| 'insert.block object'
|
|
1929
|
+
| 'insert.inline object'
|
|
1930
|
+
| 'insert.break'
|
|
1931
|
+
| 'insert.soft break'
|
|
1932
|
+
| 'insert.block'
|
|
1933
|
+
| 'insert.span'
|
|
1934
|
+
| 'insert.text'
|
|
1935
|
+
| 'insert.text block'
|
|
1936
|
+
| 'list item.add'
|
|
1937
|
+
| 'list item.remove'
|
|
1938
|
+
| 'list item.toggle'
|
|
1939
|
+
| 'move.block'
|
|
1940
|
+
| 'move.block down'
|
|
1941
|
+
| 'move.block up'
|
|
1942
|
+
| 'select.previous block'
|
|
1943
|
+
| 'select.next block'
|
|
1944
|
+
| 'style.add'
|
|
1945
|
+
| 'style.remove'
|
|
1946
|
+
| 'style.toggle'
|
|
1947
|
+
| 'text block.set'
|
|
1948
|
+
| 'text block.unset'
|
|
1949
|
+
| 'key.down'
|
|
1950
|
+
| 'key.up'
|
|
1951
|
+
| 'paste'
|
|
1952
|
+
| `custom.${string}`
|
|
1953
|
+
>
|
|
1954
|
+
>
|
|
1955
|
+
>
|
|
1846
1956
|
converters: Set<Converter>
|
|
1847
1957
|
keyGenerator: () => string
|
|
1848
1958
|
pendingEvents: never[]
|
package/lib/plugins/index.d.ts
CHANGED
|
@@ -46,10 +46,12 @@ import {
|
|
|
46
46
|
} from 'xstate'
|
|
47
47
|
import {GuardArgs} from 'xstate/guards'
|
|
48
48
|
import {
|
|
49
|
+
BehaviorEvent as BehaviorEvent_2,
|
|
49
50
|
BlockOffset as BlockOffset_2,
|
|
50
51
|
PortableTextMemberSchemaTypes as PortableTextMemberSchemaTypes_2,
|
|
51
52
|
} from '..'
|
|
52
53
|
import {MIMEType as MIMEType_2} from '../internal-utils/mime-type'
|
|
54
|
+
import {PickFromUnion as PickFromUnion_2} from '../type-utils'
|
|
53
55
|
|
|
54
56
|
/**
|
|
55
57
|
* @beta
|
|
@@ -1842,7 +1844,115 @@ declare const editorMachine: StateMachine<
|
|
|
1842
1844
|
AnyEventObject
|
|
1843
1845
|
>
|
|
1844
1846
|
}) => {
|
|
1845
|
-
behaviors: Set<
|
|
1847
|
+
behaviors: Set<
|
|
1848
|
+
Behavior<
|
|
1849
|
+
| 'focus'
|
|
1850
|
+
| 'delete'
|
|
1851
|
+
| 'select'
|
|
1852
|
+
| 'serialize'
|
|
1853
|
+
| 'copy'
|
|
1854
|
+
| 'serialization.failure'
|
|
1855
|
+
| 'serialization.success'
|
|
1856
|
+
| 'deserialize'
|
|
1857
|
+
| 'deserialization.failure'
|
|
1858
|
+
| 'deserialization.success'
|
|
1859
|
+
| 'annotation.add'
|
|
1860
|
+
| 'annotation.remove'
|
|
1861
|
+
| 'annotation.toggle'
|
|
1862
|
+
| 'block.set'
|
|
1863
|
+
| 'block.unset'
|
|
1864
|
+
| 'blur'
|
|
1865
|
+
| 'data transfer.set'
|
|
1866
|
+
| 'decorator.add'
|
|
1867
|
+
| 'decorator.remove'
|
|
1868
|
+
| 'decorator.toggle'
|
|
1869
|
+
| 'delete.backward'
|
|
1870
|
+
| 'delete.block'
|
|
1871
|
+
| 'delete.forward'
|
|
1872
|
+
| 'delete.text'
|
|
1873
|
+
| 'insert.blocks'
|
|
1874
|
+
| 'insert.block object'
|
|
1875
|
+
| 'insert.inline object'
|
|
1876
|
+
| 'insert.break'
|
|
1877
|
+
| 'insert.soft break'
|
|
1878
|
+
| 'insert.block'
|
|
1879
|
+
| 'insert.span'
|
|
1880
|
+
| 'insert.text'
|
|
1881
|
+
| 'insert.text block'
|
|
1882
|
+
| 'list item.add'
|
|
1883
|
+
| 'list item.remove'
|
|
1884
|
+
| 'list item.toggle'
|
|
1885
|
+
| 'move.block'
|
|
1886
|
+
| 'move.block down'
|
|
1887
|
+
| 'move.block up'
|
|
1888
|
+
| 'select.previous block'
|
|
1889
|
+
| 'select.next block'
|
|
1890
|
+
| 'style.add'
|
|
1891
|
+
| 'style.remove'
|
|
1892
|
+
| 'style.toggle'
|
|
1893
|
+
| 'text block.set'
|
|
1894
|
+
| 'text block.unset'
|
|
1895
|
+
| 'key.down'
|
|
1896
|
+
| 'key.up'
|
|
1897
|
+
| 'paste'
|
|
1898
|
+
| `custom.${string}`,
|
|
1899
|
+
true,
|
|
1900
|
+
PickFromUnion_2<
|
|
1901
|
+
BehaviorEvent_2,
|
|
1902
|
+
'type',
|
|
1903
|
+
| 'focus'
|
|
1904
|
+
| 'delete'
|
|
1905
|
+
| 'select'
|
|
1906
|
+
| 'serialize'
|
|
1907
|
+
| 'copy'
|
|
1908
|
+
| 'serialization.failure'
|
|
1909
|
+
| 'serialization.success'
|
|
1910
|
+
| 'deserialize'
|
|
1911
|
+
| 'deserialization.failure'
|
|
1912
|
+
| 'deserialization.success'
|
|
1913
|
+
| 'annotation.add'
|
|
1914
|
+
| 'annotation.remove'
|
|
1915
|
+
| 'annotation.toggle'
|
|
1916
|
+
| 'block.set'
|
|
1917
|
+
| 'block.unset'
|
|
1918
|
+
| 'blur'
|
|
1919
|
+
| 'data transfer.set'
|
|
1920
|
+
| 'decorator.add'
|
|
1921
|
+
| 'decorator.remove'
|
|
1922
|
+
| 'decorator.toggle'
|
|
1923
|
+
| 'delete.backward'
|
|
1924
|
+
| 'delete.block'
|
|
1925
|
+
| 'delete.forward'
|
|
1926
|
+
| 'delete.text'
|
|
1927
|
+
| 'insert.blocks'
|
|
1928
|
+
| 'insert.block object'
|
|
1929
|
+
| 'insert.inline object'
|
|
1930
|
+
| 'insert.break'
|
|
1931
|
+
| 'insert.soft break'
|
|
1932
|
+
| 'insert.block'
|
|
1933
|
+
| 'insert.span'
|
|
1934
|
+
| 'insert.text'
|
|
1935
|
+
| 'insert.text block'
|
|
1936
|
+
| 'list item.add'
|
|
1937
|
+
| 'list item.remove'
|
|
1938
|
+
| 'list item.toggle'
|
|
1939
|
+
| 'move.block'
|
|
1940
|
+
| 'move.block down'
|
|
1941
|
+
| 'move.block up'
|
|
1942
|
+
| 'select.previous block'
|
|
1943
|
+
| 'select.next block'
|
|
1944
|
+
| 'style.add'
|
|
1945
|
+
| 'style.remove'
|
|
1946
|
+
| 'style.toggle'
|
|
1947
|
+
| 'text block.set'
|
|
1948
|
+
| 'text block.unset'
|
|
1949
|
+
| 'key.down'
|
|
1950
|
+
| 'key.up'
|
|
1951
|
+
| 'paste'
|
|
1952
|
+
| `custom.${string}`
|
|
1953
|
+
>
|
|
1954
|
+
>
|
|
1955
|
+
>
|
|
1846
1956
|
converters: Set<Converter>
|
|
1847
1957
|
keyGenerator: () => string
|
|
1848
1958
|
pendingEvents: never[]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/editor",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.2",
|
|
4
4
|
"description": "Portable Text Editor made in React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"slate-react": "0.112.1",
|
|
80
80
|
"use-effect-event": "^1.0.2",
|
|
81
81
|
"xstate": "^5.19.2",
|
|
82
|
-
"@portabletext/
|
|
83
|
-
"@portabletext/
|
|
82
|
+
"@portabletext/patches": "1.1.2",
|
|
83
|
+
"@portabletext/block-tools": "1.1.4"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@portabletext/toolkit": "^2.0.16",
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"@typescript-eslint/eslint-plugin": "^8.18.1",
|
|
99
99
|
"@typescript-eslint/parser": "^8.18.1",
|
|
100
100
|
"@vitejs/plugin-react": "^4.3.4",
|
|
101
|
-
"@vitest/browser": "^3.0.
|
|
102
|
-
"@vitest/coverage-istanbul": "^3.0.
|
|
101
|
+
"@vitest/browser": "^3.0.5",
|
|
102
|
+
"@vitest/coverage-istanbul": "^3.0.5",
|
|
103
103
|
"babel-plugin-react-compiler": "19.0.0-beta-714736e-20250131",
|
|
104
104
|
"eslint": "8.57.1",
|
|
105
105
|
"eslint-plugin-react-compiler": "19.0.0-beta-714736e-20250131",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"rxjs": "^7.8.1",
|
|
111
111
|
"typescript": "5.7.3",
|
|
112
112
|
"vite": "^6.0.11",
|
|
113
|
-
"vitest": "^3.0.
|
|
113
|
+
"vitest": "^3.0.5",
|
|
114
114
|
"vitest-browser-react": "^0.0.4",
|
|
115
115
|
"racejar": "1.1.2"
|
|
116
116
|
},
|
|
@@ -40,17 +40,3 @@ export const coreBehaviors = [
|
|
|
40
40
|
coreStyleBehaviors.toggleStyleOff,
|
|
41
41
|
coreStyleBehaviors.toggleStyleOn,
|
|
42
42
|
]
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @beta
|
|
46
|
-
*/
|
|
47
|
-
export const coreBehavior = {
|
|
48
|
-
annotation: coreAnnotationBehaviors,
|
|
49
|
-
decorators: coreDecoratorBehaviors,
|
|
50
|
-
deserialize: coreDeserializeBehaviors,
|
|
51
|
-
blockObjects: coreBlockObjectBehaviors,
|
|
52
|
-
insertBreak: coreInsertBreakBehaviors,
|
|
53
|
-
lists: coreListBehaviors,
|
|
54
|
-
...coreSerializeBehaviors,
|
|
55
|
-
style: coreSerializeBehaviors,
|
|
56
|
-
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {keyIs} from '../internal-utils/key-is'
|
|
2
|
+
import {defineBehavior, raise} from './behavior.types'
|
|
3
|
+
|
|
4
|
+
export const foundationalBehaviors = [
|
|
5
|
+
/**
|
|
6
|
+
* On WebKit, Shift+Enter results in an `insertParagraph` input event rather
|
|
7
|
+
* than an `insertLineBreak` input event. This Behavior makes sure we catch
|
|
8
|
+
* that `key.down` event beforehand and raise an `insert.soft break` manually.
|
|
9
|
+
*/
|
|
10
|
+
defineBehavior({
|
|
11
|
+
on: 'key.down',
|
|
12
|
+
guard: ({event}) => keyIs.lineBreak(event.keyboardEvent),
|
|
13
|
+
actions: [() => [raise({type: 'insert.soft break'})]],
|
|
14
|
+
}),
|
|
15
|
+
]
|
package/src/behaviors/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ export {
|
|
|
10
10
|
createCodeEditorBehaviors,
|
|
11
11
|
type CodeEditorBehaviorsConfig,
|
|
12
12
|
} from './behavior.code-editor'
|
|
13
|
-
export {
|
|
13
|
+
export {coreBehaviors} from './behavior.core'
|
|
14
14
|
export {
|
|
15
15
|
type EmojiPickerBehaviorsConfig,
|
|
16
16
|
createEmojiPickerBehaviors,
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from 'xstate'
|
|
13
13
|
import {performAction} from '../behavior-actions/behavior.actions'
|
|
14
14
|
import {coreBehaviors} from '../behaviors/behavior.core'
|
|
15
|
+
import {foundationalBehaviors} from '../behaviors/behavior.foundational'
|
|
15
16
|
import {
|
|
16
17
|
isCustomBehaviorEvent,
|
|
17
18
|
type Behavior,
|
|
@@ -252,7 +253,7 @@ export const editorMachine = setup({
|
|
|
252
253
|
'assign behaviors': assign({
|
|
253
254
|
behaviors: ({event}) => {
|
|
254
255
|
assertEvent(event, 'update behaviors')
|
|
255
|
-
return new Set(event.behaviors)
|
|
256
|
+
return new Set([...foundationalBehaviors, ...event.behaviors])
|
|
256
257
|
},
|
|
257
258
|
}),
|
|
258
259
|
'assign schema': assign({
|
|
@@ -481,7 +482,10 @@ export const editorMachine = setup({
|
|
|
481
482
|
}).createMachine({
|
|
482
483
|
id: 'editor',
|
|
483
484
|
context: ({input}) => ({
|
|
484
|
-
behaviors: new Set(
|
|
485
|
+
behaviors: new Set([
|
|
486
|
+
...foundationalBehaviors,
|
|
487
|
+
...(input.behaviors ?? coreBehaviors),
|
|
488
|
+
]),
|
|
485
489
|
converters: new Set(input.converters ?? []),
|
|
486
490
|
keyGenerator: input.keyGenerator,
|
|
487
491
|
pendingEvents: [],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {Editor} from 'slate'
|
|
2
|
+
import {insertSoftBreakActionImplementation} from '../../behavior-actions/behavior.action.insert-break'
|
|
2
3
|
import {toPortableTextRange} from '../../internal-utils/ranges'
|
|
3
4
|
import {fromSlateValue} from '../../internal-utils/values'
|
|
4
5
|
import {KEY_TO_VALUE_ELEMENT} from '../../internal-utils/weakMaps'
|
|
@@ -63,7 +64,6 @@ export function createWithEventListeners(
|
|
|
63
64
|
deleteForward,
|
|
64
65
|
insertBreak,
|
|
65
66
|
insertData,
|
|
66
|
-
insertSoftBreak,
|
|
67
67
|
insertText,
|
|
68
68
|
select,
|
|
69
69
|
setFragmentData,
|
|
@@ -138,7 +138,13 @@ export function createWithEventListeners(
|
|
|
138
138
|
|
|
139
139
|
editor.insertSoftBreak = () => {
|
|
140
140
|
if (isApplyingBehaviorActions(editor)) {
|
|
141
|
-
|
|
141
|
+
insertSoftBreakActionImplementation({
|
|
142
|
+
context: {
|
|
143
|
+
keyGenerator: editorActor.getSnapshot().context.keyGenerator,
|
|
144
|
+
schema: editorActor.getSnapshot().context.schema,
|
|
145
|
+
},
|
|
146
|
+
action: {type: 'insert.soft break', editor},
|
|
147
|
+
})
|
|
142
148
|
return
|
|
143
149
|
}
|
|
144
150
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const keyIs = {
|
|
2
|
+
lineBreak: (event) => event.key === 'Enter' && event.shiftKey,
|
|
3
|
+
} satisfies Record<string, KeyboardEventPredicate>
|
|
4
|
+
|
|
5
|
+
type KeyboardEventPredicate = (
|
|
6
|
+
event: Pick<
|
|
7
|
+
KeyboardEvent,
|
|
8
|
+
'key' | 'code' | 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'
|
|
9
|
+
>,
|
|
10
|
+
) => boolean
|