@portabletext/editor 1.3.0 → 1.3.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.
- package/lib/index.d.mts +172 -1
- package/lib/index.d.ts +172 -1
- package/lib/index.esm.js +109 -73
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +109 -73
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +109 -73
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/editor/PortableTextEditor.tsx +64 -32
- package/src/editor/components/SlateContainer.tsx +2 -13
- package/src/editor/components/Synchronizer.tsx +25 -28
- package/src/editor/editor-machine.ts +11 -0
- package/src/editor/plugins/createWithPatches.ts +8 -13
- package/src/editor/plugins/createWithUndoRedo.ts +34 -33
- package/src/editor/plugins/index.ts +2 -4
- package/src/index.ts +1 -0
- package/src/types/options.ts +0 -2
package/lib/index.d.ts
CHANGED
|
@@ -291,7 +291,6 @@ export declare type ConnectionChange = {
|
|
|
291
291
|
*/
|
|
292
292
|
export declare type createEditorOptions = {
|
|
293
293
|
editorActor: EditorActor
|
|
294
|
-
patches$?: PatchObservable
|
|
295
294
|
portableTextEditor: PortableTextEditor
|
|
296
295
|
readOnly: boolean
|
|
297
296
|
maxBlocks?: number
|
|
@@ -432,6 +431,7 @@ export declare const editorMachine: StateMachine<
|
|
|
432
431
|
| {
|
|
433
432
|
type: 'ready'
|
|
434
433
|
}
|
|
434
|
+
| PatchesEvent
|
|
435
435
|
| {
|
|
436
436
|
type: 'unset'
|
|
437
437
|
previousValue: Array<PortableTextBlock>
|
|
@@ -535,6 +535,7 @@ export declare const editorMachine: StateMachine<
|
|
|
535
535
|
| {
|
|
536
536
|
type: 'ready'
|
|
537
537
|
}
|
|
538
|
+
| PatchesEvent
|
|
538
539
|
| {
|
|
539
540
|
type: 'unset'
|
|
540
541
|
previousValue: Array<PortableTextBlock>
|
|
@@ -689,6 +690,7 @@ export declare const editorMachine: StateMachine<
|
|
|
689
690
|
| {
|
|
690
691
|
type: 'ready'
|
|
691
692
|
}
|
|
693
|
+
| PatchesEvent
|
|
692
694
|
| {
|
|
693
695
|
type: 'unset'
|
|
694
696
|
previousValue: Array<PortableTextBlock>
|
|
@@ -764,6 +766,7 @@ export declare const editorMachine: StateMachine<
|
|
|
764
766
|
| {
|
|
765
767
|
type: 'ready'
|
|
766
768
|
}
|
|
769
|
+
| PatchesEvent
|
|
767
770
|
| {
|
|
768
771
|
type: 'unset'
|
|
769
772
|
previousValue: Array<PortableTextBlock>
|
|
@@ -856,6 +859,7 @@ export declare const editorMachine: StateMachine<
|
|
|
856
859
|
| {
|
|
857
860
|
type: 'ready'
|
|
858
861
|
}
|
|
862
|
+
| PatchesEvent
|
|
859
863
|
| {
|
|
860
864
|
type: 'unset'
|
|
861
865
|
previousValue: Array<PortableTextBlock>
|
|
@@ -909,6 +913,7 @@ export declare const editorMachine: StateMachine<
|
|
|
909
913
|
| {
|
|
910
914
|
type: 'ready'
|
|
911
915
|
}
|
|
916
|
+
| PatchesEvent
|
|
912
917
|
| {
|
|
913
918
|
type: 'unset'
|
|
914
919
|
previousValue: Array<PortableTextBlock>
|
|
@@ -991,6 +996,7 @@ export declare const editorMachine: StateMachine<
|
|
|
991
996
|
| {
|
|
992
997
|
type: 'ready'
|
|
993
998
|
}
|
|
999
|
+
| PatchesEvent
|
|
994
1000
|
| {
|
|
995
1001
|
type: 'unset'
|
|
996
1002
|
previousValue: Array<PortableTextBlock>
|
|
@@ -1044,6 +1050,7 @@ export declare const editorMachine: StateMachine<
|
|
|
1044
1050
|
| {
|
|
1045
1051
|
type: 'ready'
|
|
1046
1052
|
}
|
|
1053
|
+
| PatchesEvent
|
|
1047
1054
|
| {
|
|
1048
1055
|
type: 'unset'
|
|
1049
1056
|
previousValue: Array<PortableTextBlock>
|
|
@@ -1126,6 +1133,7 @@ export declare const editorMachine: StateMachine<
|
|
|
1126
1133
|
| {
|
|
1127
1134
|
type: 'ready'
|
|
1128
1135
|
}
|
|
1136
|
+
| PatchesEvent
|
|
1129
1137
|
| {
|
|
1130
1138
|
type: 'unset'
|
|
1131
1139
|
previousValue: Array<PortableTextBlock>
|
|
@@ -1179,6 +1187,7 @@ export declare const editorMachine: StateMachine<
|
|
|
1179
1187
|
| {
|
|
1180
1188
|
type: 'ready'
|
|
1181
1189
|
}
|
|
1190
|
+
| PatchesEvent
|
|
1182
1191
|
| {
|
|
1183
1192
|
type: 'unset'
|
|
1184
1193
|
previousValue: Array<PortableTextBlock>
|
|
@@ -1262,6 +1271,7 @@ export declare const editorMachine: StateMachine<
|
|
|
1262
1271
|
| {
|
|
1263
1272
|
type: 'ready'
|
|
1264
1273
|
}
|
|
1274
|
+
| PatchesEvent
|
|
1265
1275
|
| {
|
|
1266
1276
|
type: 'unset'
|
|
1267
1277
|
previousValue: Array<PortableTextBlock>
|
|
@@ -1315,6 +1325,7 @@ export declare const editorMachine: StateMachine<
|
|
|
1315
1325
|
| {
|
|
1316
1326
|
type: 'ready'
|
|
1317
1327
|
}
|
|
1328
|
+
| PatchesEvent
|
|
1318
1329
|
| {
|
|
1319
1330
|
type: 'unset'
|
|
1320
1331
|
previousValue: Array<PortableTextBlock>
|
|
@@ -1399,6 +1410,7 @@ export declare const editorMachine: StateMachine<
|
|
|
1399
1410
|
| {
|
|
1400
1411
|
type: 'ready'
|
|
1401
1412
|
}
|
|
1413
|
+
| PatchesEvent
|
|
1402
1414
|
| {
|
|
1403
1415
|
type: 'unset'
|
|
1404
1416
|
previousValue: Array<PortableTextBlock>
|
|
@@ -1452,6 +1464,7 @@ export declare const editorMachine: StateMachine<
|
|
|
1452
1464
|
| {
|
|
1453
1465
|
type: 'ready'
|
|
1454
1466
|
}
|
|
1467
|
+
| PatchesEvent
|
|
1455
1468
|
| {
|
|
1456
1469
|
type: 'unset'
|
|
1457
1470
|
previousValue: Array<PortableTextBlock>
|
|
@@ -1534,6 +1547,7 @@ export declare const editorMachine: StateMachine<
|
|
|
1534
1547
|
| {
|
|
1535
1548
|
type: 'ready'
|
|
1536
1549
|
}
|
|
1550
|
+
| PatchesEvent
|
|
1537
1551
|
| {
|
|
1538
1552
|
type: 'unset'
|
|
1539
1553
|
previousValue: Array<PortableTextBlock>
|
|
@@ -1587,6 +1601,7 @@ export declare const editorMachine: StateMachine<
|
|
|
1587
1601
|
| {
|
|
1588
1602
|
type: 'ready'
|
|
1589
1603
|
}
|
|
1604
|
+
| PatchesEvent
|
|
1590
1605
|
| {
|
|
1591
1606
|
type: 'unset'
|
|
1592
1607
|
previousValue: Array<PortableTextBlock>
|
|
@@ -1669,6 +1684,7 @@ export declare const editorMachine: StateMachine<
|
|
|
1669
1684
|
| {
|
|
1670
1685
|
type: 'ready'
|
|
1671
1686
|
}
|
|
1687
|
+
| PatchesEvent
|
|
1672
1688
|
| {
|
|
1673
1689
|
type: 'unset'
|
|
1674
1690
|
previousValue: Array<PortableTextBlock>
|
|
@@ -1722,6 +1738,7 @@ export declare const editorMachine: StateMachine<
|
|
|
1722
1738
|
| {
|
|
1723
1739
|
type: 'ready'
|
|
1724
1740
|
}
|
|
1741
|
+
| PatchesEvent
|
|
1725
1742
|
| {
|
|
1726
1743
|
type: 'unset'
|
|
1727
1744
|
previousValue: Array<PortableTextBlock>
|
|
@@ -1804,6 +1821,7 @@ export declare const editorMachine: StateMachine<
|
|
|
1804
1821
|
| {
|
|
1805
1822
|
type: 'ready'
|
|
1806
1823
|
}
|
|
1824
|
+
| PatchesEvent
|
|
1807
1825
|
| {
|
|
1808
1826
|
type: 'unset'
|
|
1809
1827
|
previousValue: Array<PortableTextBlock>
|
|
@@ -1857,6 +1875,7 @@ export declare const editorMachine: StateMachine<
|
|
|
1857
1875
|
| {
|
|
1858
1876
|
type: 'ready'
|
|
1859
1877
|
}
|
|
1878
|
+
| PatchesEvent
|
|
1860
1879
|
| {
|
|
1861
1880
|
type: 'unset'
|
|
1862
1881
|
previousValue: Array<PortableTextBlock>
|
|
@@ -1938,6 +1957,7 @@ export declare const editorMachine: StateMachine<
|
|
|
1938
1957
|
| {
|
|
1939
1958
|
type: 'ready'
|
|
1940
1959
|
}
|
|
1960
|
+
| PatchesEvent
|
|
1941
1961
|
| {
|
|
1942
1962
|
type: 'unset'
|
|
1943
1963
|
previousValue: Array<PortableTextBlock>
|
|
@@ -1991,6 +2011,7 @@ export declare const editorMachine: StateMachine<
|
|
|
1991
2011
|
| {
|
|
1992
2012
|
type: 'ready'
|
|
1993
2013
|
}
|
|
2014
|
+
| PatchesEvent
|
|
1994
2015
|
| {
|
|
1995
2016
|
type: 'unset'
|
|
1996
2017
|
previousValue: Array<PortableTextBlock>
|
|
@@ -2072,6 +2093,7 @@ export declare const editorMachine: StateMachine<
|
|
|
2072
2093
|
| {
|
|
2073
2094
|
type: 'ready'
|
|
2074
2095
|
}
|
|
2096
|
+
| PatchesEvent
|
|
2075
2097
|
| {
|
|
2076
2098
|
type: 'unset'
|
|
2077
2099
|
previousValue: Array<PortableTextBlock>
|
|
@@ -2125,6 +2147,7 @@ export declare const editorMachine: StateMachine<
|
|
|
2125
2147
|
| {
|
|
2126
2148
|
type: 'ready'
|
|
2127
2149
|
}
|
|
2150
|
+
| PatchesEvent
|
|
2128
2151
|
| {
|
|
2129
2152
|
type: 'unset'
|
|
2130
2153
|
previousValue: Array<PortableTextBlock>
|
|
@@ -2206,6 +2229,141 @@ export declare const editorMachine: StateMachine<
|
|
|
2206
2229
|
| {
|
|
2207
2230
|
type: 'ready'
|
|
2208
2231
|
}
|
|
2232
|
+
| PatchesEvent
|
|
2233
|
+
| {
|
|
2234
|
+
type: 'unset'
|
|
2235
|
+
previousValue: Array<PortableTextBlock>
|
|
2236
|
+
}
|
|
2237
|
+
| {
|
|
2238
|
+
type: 'value changed'
|
|
2239
|
+
value: Array<PortableTextBlock> | undefined
|
|
2240
|
+
}
|
|
2241
|
+
| {
|
|
2242
|
+
type: 'invalid value'
|
|
2243
|
+
resolution: InvalidValueResolution | null
|
|
2244
|
+
value: Array<PortableTextBlock> | undefined
|
|
2245
|
+
}
|
|
2246
|
+
| {
|
|
2247
|
+
type: 'error'
|
|
2248
|
+
name: string
|
|
2249
|
+
description: string
|
|
2250
|
+
data: unknown
|
|
2251
|
+
}
|
|
2252
|
+
| {
|
|
2253
|
+
type: 'selection'
|
|
2254
|
+
selection: EditorSelection
|
|
2255
|
+
}
|
|
2256
|
+
| {
|
|
2257
|
+
type: 'blur'
|
|
2258
|
+
event: FocusEvent_2<HTMLDivElement, Element>
|
|
2259
|
+
}
|
|
2260
|
+
| {
|
|
2261
|
+
type: 'focus'
|
|
2262
|
+
event: FocusEvent_2<HTMLDivElement, Element>
|
|
2263
|
+
}
|
|
2264
|
+
| {
|
|
2265
|
+
type: 'online'
|
|
2266
|
+
}
|
|
2267
|
+
| {
|
|
2268
|
+
type: 'offline'
|
|
2269
|
+
}
|
|
2270
|
+
| {
|
|
2271
|
+
type: 'loading'
|
|
2272
|
+
}
|
|
2273
|
+
| {
|
|
2274
|
+
type: 'done loading'
|
|
2275
|
+
},
|
|
2276
|
+
undefined,
|
|
2277
|
+
never,
|
|
2278
|
+
never,
|
|
2279
|
+
never,
|
|
2280
|
+
never,
|
|
2281
|
+
| PatchEvent
|
|
2282
|
+
| MutationEvent_2
|
|
2283
|
+
| {
|
|
2284
|
+
type: 'ready'
|
|
2285
|
+
}
|
|
2286
|
+
| PatchesEvent
|
|
2287
|
+
| {
|
|
2288
|
+
type: 'unset'
|
|
2289
|
+
previousValue: Array<PortableTextBlock>
|
|
2290
|
+
}
|
|
2291
|
+
| {
|
|
2292
|
+
type: 'value changed'
|
|
2293
|
+
value: Array<PortableTextBlock> | undefined
|
|
2294
|
+
}
|
|
2295
|
+
| {
|
|
2296
|
+
type: 'invalid value'
|
|
2297
|
+
resolution: InvalidValueResolution | null
|
|
2298
|
+
value: Array<PortableTextBlock> | undefined
|
|
2299
|
+
}
|
|
2300
|
+
| {
|
|
2301
|
+
type: 'error'
|
|
2302
|
+
name: string
|
|
2303
|
+
description: string
|
|
2304
|
+
data: unknown
|
|
2305
|
+
}
|
|
2306
|
+
| {
|
|
2307
|
+
type: 'selection'
|
|
2308
|
+
selection: EditorSelection
|
|
2309
|
+
}
|
|
2310
|
+
| {
|
|
2311
|
+
type: 'blur'
|
|
2312
|
+
event: FocusEvent_2<HTMLDivElement, Element>
|
|
2313
|
+
}
|
|
2314
|
+
| {
|
|
2315
|
+
type: 'focus'
|
|
2316
|
+
event: FocusEvent_2<HTMLDivElement, Element>
|
|
2317
|
+
}
|
|
2318
|
+
| {
|
|
2319
|
+
type: 'online'
|
|
2320
|
+
}
|
|
2321
|
+
| {
|
|
2322
|
+
type: 'offline'
|
|
2323
|
+
}
|
|
2324
|
+
| {
|
|
2325
|
+
type: 'loading'
|
|
2326
|
+
}
|
|
2327
|
+
| {
|
|
2328
|
+
type: 'done loading'
|
|
2329
|
+
}
|
|
2330
|
+
>
|
|
2331
|
+
}
|
|
2332
|
+
readonly 'patches': {
|
|
2333
|
+
readonly actions: ActionFunction<
|
|
2334
|
+
{
|
|
2335
|
+
behaviors: Array<Behavior>
|
|
2336
|
+
keyGenerator: () => string
|
|
2337
|
+
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
2338
|
+
schema: PortableTextMemberSchemaTypes
|
|
2339
|
+
},
|
|
2340
|
+
PatchesEvent,
|
|
2341
|
+
| PatchEvent
|
|
2342
|
+
| MutationEvent_2
|
|
2343
|
+
| {
|
|
2344
|
+
type: 'normalizing'
|
|
2345
|
+
}
|
|
2346
|
+
| {
|
|
2347
|
+
type: 'done normalizing'
|
|
2348
|
+
}
|
|
2349
|
+
| {
|
|
2350
|
+
type: 'behavior event'
|
|
2351
|
+
behaviorEvent: BehaviorEvent
|
|
2352
|
+
editor: PortableTextSlateEditor
|
|
2353
|
+
}
|
|
2354
|
+
| {
|
|
2355
|
+
type: 'behavior action intends'
|
|
2356
|
+
editor: PortableTextSlateEditor
|
|
2357
|
+
actionIntends: Array<BehaviorActionIntend>
|
|
2358
|
+
}
|
|
2359
|
+
| {
|
|
2360
|
+
type: 'update schema'
|
|
2361
|
+
schema: PortableTextMemberSchemaTypes
|
|
2362
|
+
}
|
|
2363
|
+
| {
|
|
2364
|
+
type: 'ready'
|
|
2365
|
+
}
|
|
2366
|
+
| PatchesEvent
|
|
2209
2367
|
| {
|
|
2210
2368
|
type: 'unset'
|
|
2211
2369
|
previousValue: Array<PortableTextBlock>
|
|
@@ -2259,6 +2417,7 @@ export declare const editorMachine: StateMachine<
|
|
|
2259
2417
|
| {
|
|
2260
2418
|
type: 'ready'
|
|
2261
2419
|
}
|
|
2420
|
+
| PatchesEvent
|
|
2262
2421
|
| {
|
|
2263
2422
|
type: 'unset'
|
|
2264
2423
|
previousValue: Array<PortableTextBlock>
|
|
@@ -2340,6 +2499,7 @@ export declare const editorMachine: StateMachine<
|
|
|
2340
2499
|
| {
|
|
2341
2500
|
type: 'ready'
|
|
2342
2501
|
}
|
|
2502
|
+
| PatchesEvent
|
|
2343
2503
|
| {
|
|
2344
2504
|
type: 'unset'
|
|
2345
2505
|
previousValue: Array<PortableTextBlock>
|
|
@@ -2393,6 +2553,7 @@ export declare const editorMachine: StateMachine<
|
|
|
2393
2553
|
| {
|
|
2394
2554
|
type: 'ready'
|
|
2395
2555
|
}
|
|
2556
|
+
| PatchesEvent
|
|
2396
2557
|
| {
|
|
2397
2558
|
type: 'unset'
|
|
2398
2559
|
previousValue: Array<PortableTextBlock>
|
|
@@ -2486,6 +2647,7 @@ export declare const editorMachine: StateMachine<
|
|
|
2486
2647
|
| {
|
|
2487
2648
|
type: 'ready'
|
|
2488
2649
|
}
|
|
2650
|
+
| PatchesEvent
|
|
2489
2651
|
| {
|
|
2490
2652
|
type: 'unset'
|
|
2491
2653
|
previousValue: Array<PortableTextBlock>
|
|
@@ -2759,6 +2921,15 @@ export declare type PatchChange = {
|
|
|
2759
2921
|
patch: Patch
|
|
2760
2922
|
}
|
|
2761
2923
|
|
|
2924
|
+
/**
|
|
2925
|
+
* @internal
|
|
2926
|
+
*/
|
|
2927
|
+
export declare type PatchesEvent = {
|
|
2928
|
+
type: 'patches'
|
|
2929
|
+
patches: Array<Patch>
|
|
2930
|
+
snapshot: Array<PortableTextBlock> | undefined
|
|
2931
|
+
}
|
|
2932
|
+
|
|
2762
2933
|
/**
|
|
2763
2934
|
* @internal
|
|
2764
2935
|
*/
|