@portabletext/editor 1.5.1 → 1.5.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/README.md +1 -1
- package/lib/index.d.mts +74 -18
- package/lib/index.d.ts +74 -18
- package/lib/index.esm.js +151 -133
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +151 -133
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +151 -133
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/editor/behavior/behavior.core.block-objects.ts +4 -4
- package/src/editor/behavior/behavior.core.lists.ts +1 -1
- package/src/editor/behavior/behavior.core.ts +17 -2
- package/src/editor/behavior/behavior.markdown.ts +5 -0
- package/src/editor/editor-machine.ts +2 -4
- package/src/index.ts +2 -1
package/README.md
CHANGED
package/lib/index.d.mts
CHANGED
|
@@ -297,6 +297,76 @@ export declare type ConnectionChange = {
|
|
|
297
297
|
value: 'online' | 'offline'
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
/**
|
|
301
|
+
* @alpha
|
|
302
|
+
*/
|
|
303
|
+
export declare const coreBehavior: {
|
|
304
|
+
softReturn: Behavior<
|
|
305
|
+
| 'insert break'
|
|
306
|
+
| 'insert soft break'
|
|
307
|
+
| 'delete backward'
|
|
308
|
+
| 'delete forward'
|
|
309
|
+
| 'insert text',
|
|
310
|
+
true
|
|
311
|
+
>
|
|
312
|
+
blockObjects: {
|
|
313
|
+
breakingBlockObject: Behavior<
|
|
314
|
+
| 'insert break'
|
|
315
|
+
| 'insert soft break'
|
|
316
|
+
| 'delete backward'
|
|
317
|
+
| 'delete forward'
|
|
318
|
+
| 'insert text',
|
|
319
|
+
true
|
|
320
|
+
>
|
|
321
|
+
deletingEmptyTextBlockAfterBlockObject: Behavior<
|
|
322
|
+
| 'insert break'
|
|
323
|
+
| 'insert soft break'
|
|
324
|
+
| 'delete backward'
|
|
325
|
+
| 'delete forward'
|
|
326
|
+
| 'insert text',
|
|
327
|
+
true
|
|
328
|
+
>
|
|
329
|
+
deletingEmptyTextBlockBeforeBlockObject: Behavior<
|
|
330
|
+
| 'insert break'
|
|
331
|
+
| 'insert soft break'
|
|
332
|
+
| 'delete backward'
|
|
333
|
+
| 'delete forward'
|
|
334
|
+
| 'insert text',
|
|
335
|
+
true
|
|
336
|
+
>
|
|
337
|
+
}
|
|
338
|
+
lists: {
|
|
339
|
+
clearListOnBackspace: Behavior<
|
|
340
|
+
| 'insert break'
|
|
341
|
+
| 'insert soft break'
|
|
342
|
+
| 'delete backward'
|
|
343
|
+
| 'delete forward'
|
|
344
|
+
| 'insert text',
|
|
345
|
+
true
|
|
346
|
+
>
|
|
347
|
+
unindentListOnBackspace: Behavior<
|
|
348
|
+
| 'insert break'
|
|
349
|
+
| 'insert soft break'
|
|
350
|
+
| 'delete backward'
|
|
351
|
+
| 'delete forward'
|
|
352
|
+
| 'insert text',
|
|
353
|
+
true
|
|
354
|
+
>
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @alpha
|
|
360
|
+
*/
|
|
361
|
+
export declare const coreBehaviors: Behavior<
|
|
362
|
+
| 'insert break'
|
|
363
|
+
| 'insert soft break'
|
|
364
|
+
| 'delete backward'
|
|
365
|
+
| 'delete forward'
|
|
366
|
+
| 'insert text',
|
|
367
|
+
true
|
|
368
|
+
>[]
|
|
369
|
+
|
|
300
370
|
/**
|
|
301
371
|
* @internal
|
|
302
372
|
*/
|
|
@@ -313,10 +383,10 @@ export declare type createEditorOptions = {
|
|
|
313
383
|
export declare function createMarkdownBehaviors(
|
|
314
384
|
config: MarkdownBehaviorsConfig,
|
|
315
385
|
): Behavior<
|
|
386
|
+
| 'insert break'
|
|
387
|
+
| 'insert soft break'
|
|
316
388
|
| 'delete backward'
|
|
317
389
|
| 'delete forward'
|
|
318
|
-
| 'insert soft break'
|
|
319
|
-
| 'insert break'
|
|
320
390
|
| 'insert text',
|
|
321
391
|
true
|
|
322
392
|
>[]
|
|
@@ -909,14 +979,7 @@ export declare const editorMachine: StateMachine<
|
|
|
909
979
|
AnyEventObject
|
|
910
980
|
>
|
|
911
981
|
}) => {
|
|
912
|
-
behaviors: Behavior
|
|
913
|
-
| 'delete backward'
|
|
914
|
-
| 'delete forward'
|
|
915
|
-
| 'insert soft break'
|
|
916
|
-
| 'insert break'
|
|
917
|
-
| 'insert text',
|
|
918
|
-
true
|
|
919
|
-
>[]
|
|
982
|
+
behaviors: Behavior[]
|
|
920
983
|
keyGenerator: () => string
|
|
921
984
|
pendingEvents: never[]
|
|
922
985
|
schema: PortableTextMemberSchemaTypes
|
|
@@ -4091,14 +4154,7 @@ export declare function useEditor(config: EditorConfig): Actor<
|
|
|
4091
4154
|
AnyEventObject
|
|
4092
4155
|
>
|
|
4093
4156
|
}) => {
|
|
4094
|
-
behaviors: Behavior
|
|
4095
|
-
| 'delete backward'
|
|
4096
|
-
| 'delete forward'
|
|
4097
|
-
| 'insert soft break'
|
|
4098
|
-
| 'insert break'
|
|
4099
|
-
| 'insert text',
|
|
4100
|
-
true
|
|
4101
|
-
>[]
|
|
4157
|
+
behaviors: Behavior[]
|
|
4102
4158
|
keyGenerator: () => string
|
|
4103
4159
|
pendingEvents: never[]
|
|
4104
4160
|
schema: PortableTextMemberSchemaTypes
|
package/lib/index.d.ts
CHANGED
|
@@ -297,6 +297,76 @@ export declare type ConnectionChange = {
|
|
|
297
297
|
value: 'online' | 'offline'
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
/**
|
|
301
|
+
* @alpha
|
|
302
|
+
*/
|
|
303
|
+
export declare const coreBehavior: {
|
|
304
|
+
softReturn: Behavior<
|
|
305
|
+
| 'insert break'
|
|
306
|
+
| 'insert soft break'
|
|
307
|
+
| 'delete backward'
|
|
308
|
+
| 'delete forward'
|
|
309
|
+
| 'insert text',
|
|
310
|
+
true
|
|
311
|
+
>
|
|
312
|
+
blockObjects: {
|
|
313
|
+
breakingBlockObject: Behavior<
|
|
314
|
+
| 'insert break'
|
|
315
|
+
| 'insert soft break'
|
|
316
|
+
| 'delete backward'
|
|
317
|
+
| 'delete forward'
|
|
318
|
+
| 'insert text',
|
|
319
|
+
true
|
|
320
|
+
>
|
|
321
|
+
deletingEmptyTextBlockAfterBlockObject: Behavior<
|
|
322
|
+
| 'insert break'
|
|
323
|
+
| 'insert soft break'
|
|
324
|
+
| 'delete backward'
|
|
325
|
+
| 'delete forward'
|
|
326
|
+
| 'insert text',
|
|
327
|
+
true
|
|
328
|
+
>
|
|
329
|
+
deletingEmptyTextBlockBeforeBlockObject: Behavior<
|
|
330
|
+
| 'insert break'
|
|
331
|
+
| 'insert soft break'
|
|
332
|
+
| 'delete backward'
|
|
333
|
+
| 'delete forward'
|
|
334
|
+
| 'insert text',
|
|
335
|
+
true
|
|
336
|
+
>
|
|
337
|
+
}
|
|
338
|
+
lists: {
|
|
339
|
+
clearListOnBackspace: Behavior<
|
|
340
|
+
| 'insert break'
|
|
341
|
+
| 'insert soft break'
|
|
342
|
+
| 'delete backward'
|
|
343
|
+
| 'delete forward'
|
|
344
|
+
| 'insert text',
|
|
345
|
+
true
|
|
346
|
+
>
|
|
347
|
+
unindentListOnBackspace: Behavior<
|
|
348
|
+
| 'insert break'
|
|
349
|
+
| 'insert soft break'
|
|
350
|
+
| 'delete backward'
|
|
351
|
+
| 'delete forward'
|
|
352
|
+
| 'insert text',
|
|
353
|
+
true
|
|
354
|
+
>
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @alpha
|
|
360
|
+
*/
|
|
361
|
+
export declare const coreBehaviors: Behavior<
|
|
362
|
+
| 'insert break'
|
|
363
|
+
| 'insert soft break'
|
|
364
|
+
| 'delete backward'
|
|
365
|
+
| 'delete forward'
|
|
366
|
+
| 'insert text',
|
|
367
|
+
true
|
|
368
|
+
>[]
|
|
369
|
+
|
|
300
370
|
/**
|
|
301
371
|
* @internal
|
|
302
372
|
*/
|
|
@@ -313,10 +383,10 @@ export declare type createEditorOptions = {
|
|
|
313
383
|
export declare function createMarkdownBehaviors(
|
|
314
384
|
config: MarkdownBehaviorsConfig,
|
|
315
385
|
): Behavior<
|
|
386
|
+
| 'insert break'
|
|
387
|
+
| 'insert soft break'
|
|
316
388
|
| 'delete backward'
|
|
317
389
|
| 'delete forward'
|
|
318
|
-
| 'insert soft break'
|
|
319
|
-
| 'insert break'
|
|
320
390
|
| 'insert text',
|
|
321
391
|
true
|
|
322
392
|
>[]
|
|
@@ -909,14 +979,7 @@ export declare const editorMachine: StateMachine<
|
|
|
909
979
|
AnyEventObject
|
|
910
980
|
>
|
|
911
981
|
}) => {
|
|
912
|
-
behaviors: Behavior
|
|
913
|
-
| 'delete backward'
|
|
914
|
-
| 'delete forward'
|
|
915
|
-
| 'insert soft break'
|
|
916
|
-
| 'insert break'
|
|
917
|
-
| 'insert text',
|
|
918
|
-
true
|
|
919
|
-
>[]
|
|
982
|
+
behaviors: Behavior[]
|
|
920
983
|
keyGenerator: () => string
|
|
921
984
|
pendingEvents: never[]
|
|
922
985
|
schema: PortableTextMemberSchemaTypes
|
|
@@ -4091,14 +4154,7 @@ export declare function useEditor(config: EditorConfig): Actor<
|
|
|
4091
4154
|
AnyEventObject
|
|
4092
4155
|
>
|
|
4093
4156
|
}) => {
|
|
4094
|
-
behaviors: Behavior
|
|
4095
|
-
| 'delete backward'
|
|
4096
|
-
| 'delete forward'
|
|
4097
|
-
| 'insert soft break'
|
|
4098
|
-
| 'insert break'
|
|
4099
|
-
| 'insert text',
|
|
4100
|
-
true
|
|
4101
|
-
>[]
|
|
4157
|
+
behaviors: Behavior[]
|
|
4102
4158
|
keyGenerator: () => string
|
|
4103
4159
|
pendingEvents: never[]
|
|
4104
4160
|
schema: PortableTextMemberSchemaTypes
|
package/lib/index.esm.js
CHANGED
|
@@ -140,6 +140,148 @@ function getNextBlock(context) {
|
|
|
140
140
|
function isEmptyTextBlock(block) {
|
|
141
141
|
return block.children.length === 1 && block.children[0].text === "";
|
|
142
142
|
}
|
|
143
|
+
const breakingBlockObject = {
|
|
144
|
+
on: "insert break",
|
|
145
|
+
guard: ({
|
|
146
|
+
context
|
|
147
|
+
}) => !!getFocusBlockObject(context),
|
|
148
|
+
actions: [() => [{
|
|
149
|
+
type: "insert text block",
|
|
150
|
+
decorators: []
|
|
151
|
+
}]]
|
|
152
|
+
}, deletingEmptyTextBlockAfterBlockObject = {
|
|
153
|
+
on: "delete backward",
|
|
154
|
+
guard: ({
|
|
155
|
+
context
|
|
156
|
+
}) => {
|
|
157
|
+
const focusTextBlock = getFocusTextBlock(context), selectionCollapsed = selectionIsCollapsed(context), previousBlock = getPreviousBlock(context);
|
|
158
|
+
return !focusTextBlock || !selectionCollapsed || !previousBlock ? !1 : isEmptyTextBlock(focusTextBlock.node) && !isPortableTextTextBlock(previousBlock.node) ? {
|
|
159
|
+
focusTextBlock,
|
|
160
|
+
previousBlock
|
|
161
|
+
} : !1;
|
|
162
|
+
},
|
|
163
|
+
actions: [(_, {
|
|
164
|
+
focusTextBlock,
|
|
165
|
+
previousBlock
|
|
166
|
+
}) => [{
|
|
167
|
+
type: "delete",
|
|
168
|
+
selection: {
|
|
169
|
+
anchor: {
|
|
170
|
+
path: focusTextBlock.path,
|
|
171
|
+
offset: 0
|
|
172
|
+
},
|
|
173
|
+
focus: {
|
|
174
|
+
path: focusTextBlock.path,
|
|
175
|
+
offset: 0
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}, {
|
|
179
|
+
type: "select",
|
|
180
|
+
selection: {
|
|
181
|
+
anchor: {
|
|
182
|
+
path: previousBlock.path,
|
|
183
|
+
offset: 0
|
|
184
|
+
},
|
|
185
|
+
focus: {
|
|
186
|
+
path: previousBlock.path,
|
|
187
|
+
offset: 0
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}]]
|
|
191
|
+
}, deletingEmptyTextBlockBeforeBlockObject = {
|
|
192
|
+
on: "delete forward",
|
|
193
|
+
guard: ({
|
|
194
|
+
context
|
|
195
|
+
}) => {
|
|
196
|
+
const focusTextBlock = getFocusTextBlock(context), selectionCollapsed = selectionIsCollapsed(context), nextBlock = getNextBlock(context);
|
|
197
|
+
return !focusTextBlock || !selectionCollapsed || !nextBlock ? !1 : isEmptyTextBlock(focusTextBlock.node) && !isPortableTextTextBlock(nextBlock.node) ? {
|
|
198
|
+
focusTextBlock,
|
|
199
|
+
nextBlock
|
|
200
|
+
} : !1;
|
|
201
|
+
},
|
|
202
|
+
actions: [(_, {
|
|
203
|
+
focusTextBlock,
|
|
204
|
+
nextBlock
|
|
205
|
+
}) => [{
|
|
206
|
+
type: "delete",
|
|
207
|
+
selection: {
|
|
208
|
+
anchor: {
|
|
209
|
+
path: focusTextBlock.path,
|
|
210
|
+
offset: 0
|
|
211
|
+
},
|
|
212
|
+
focus: {
|
|
213
|
+
path: focusTextBlock.path,
|
|
214
|
+
offset: 0
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}, {
|
|
218
|
+
type: "select",
|
|
219
|
+
selection: {
|
|
220
|
+
anchor: {
|
|
221
|
+
path: nextBlock.path,
|
|
222
|
+
offset: 0
|
|
223
|
+
},
|
|
224
|
+
focus: {
|
|
225
|
+
path: nextBlock.path,
|
|
226
|
+
offset: 0
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}]]
|
|
230
|
+
}, coreBlockObjectBehaviors = {
|
|
231
|
+
breakingBlockObject,
|
|
232
|
+
deletingEmptyTextBlockAfterBlockObject,
|
|
233
|
+
deletingEmptyTextBlockBeforeBlockObject
|
|
234
|
+
}, clearListOnBackspace = {
|
|
235
|
+
on: "delete backward",
|
|
236
|
+
guard: ({
|
|
237
|
+
context
|
|
238
|
+
}) => {
|
|
239
|
+
const selectionCollapsed = selectionIsCollapsed(context), focusTextBlock = getFocusTextBlock(context), focusSpan = getFocusSpan(context);
|
|
240
|
+
return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && context.selection.focus.offset === 0 && focusTextBlock.node.level === 1 ? {
|
|
241
|
+
focusTextBlock
|
|
242
|
+
} : !1;
|
|
243
|
+
},
|
|
244
|
+
actions: [(_, {
|
|
245
|
+
focusTextBlock
|
|
246
|
+
}) => [{
|
|
247
|
+
type: "unset block",
|
|
248
|
+
props: ["listItem", "level"],
|
|
249
|
+
paths: [focusTextBlock.path]
|
|
250
|
+
}]]
|
|
251
|
+
}, unindentListOnBackspace = {
|
|
252
|
+
on: "delete backward",
|
|
253
|
+
guard: ({
|
|
254
|
+
context
|
|
255
|
+
}) => {
|
|
256
|
+
const selectionCollapsed = selectionIsCollapsed(context), focusTextBlock = getFocusTextBlock(context), focusSpan = getFocusSpan(context);
|
|
257
|
+
return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && context.selection.focus.offset === 0 && focusTextBlock.node.level !== void 0 && focusTextBlock.node.level > 1 ? {
|
|
258
|
+
focusTextBlock,
|
|
259
|
+
level: focusTextBlock.node.level - 1
|
|
260
|
+
} : !1;
|
|
261
|
+
},
|
|
262
|
+
actions: [(_, {
|
|
263
|
+
focusTextBlock,
|
|
264
|
+
level
|
|
265
|
+
}) => [{
|
|
266
|
+
type: "set block",
|
|
267
|
+
level,
|
|
268
|
+
paths: [focusTextBlock.path]
|
|
269
|
+
}]]
|
|
270
|
+
}, coreListBehaviors = {
|
|
271
|
+
clearListOnBackspace,
|
|
272
|
+
unindentListOnBackspace
|
|
273
|
+
}, softReturn = {
|
|
274
|
+
on: "insert soft break",
|
|
275
|
+
actions: [() => [{
|
|
276
|
+
type: "insert text",
|
|
277
|
+
text: `
|
|
278
|
+
`
|
|
279
|
+
}]]
|
|
280
|
+
}, coreBehaviors = [softReturn, coreBlockObjectBehaviors.breakingBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockAfterBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockBeforeBlockObject, coreListBehaviors.clearListOnBackspace, coreListBehaviors.unindentListOnBackspace], coreBehavior = {
|
|
281
|
+
softReturn,
|
|
282
|
+
blockObjects: coreBlockObjectBehaviors,
|
|
283
|
+
lists: coreListBehaviors
|
|
284
|
+
};
|
|
143
285
|
function createMarkdownBehaviors(config) {
|
|
144
286
|
const automaticStyleOnSpace = {
|
|
145
287
|
on: "insert text",
|
|
@@ -171,6 +313,10 @@ function createMarkdownBehaviors(config) {
|
|
|
171
313
|
focusSpan,
|
|
172
314
|
style
|
|
173
315
|
}) => [{
|
|
316
|
+
type: "unset block",
|
|
317
|
+
props: ["listItem", "level"],
|
|
318
|
+
paths: [focusTextBlock.path]
|
|
319
|
+
}, {
|
|
174
320
|
type: "set block",
|
|
175
321
|
style,
|
|
176
322
|
paths: [focusTextBlock.path]
|
|
@@ -5339,137 +5485,7 @@ function performDefaultAction({
|
|
|
5339
5485
|
});
|
|
5340
5486
|
}
|
|
5341
5487
|
}
|
|
5342
|
-
const
|
|
5343
|
-
on: "insert break",
|
|
5344
|
-
guard: ({
|
|
5345
|
-
context
|
|
5346
|
-
}) => !!getFocusBlockObject(context),
|
|
5347
|
-
actions: [() => [{
|
|
5348
|
-
type: "insert text block",
|
|
5349
|
-
decorators: []
|
|
5350
|
-
}]]
|
|
5351
|
-
}, deletingEmptyTextBlockAfterBlockObject = {
|
|
5352
|
-
on: "delete backward",
|
|
5353
|
-
guard: ({
|
|
5354
|
-
context
|
|
5355
|
-
}) => {
|
|
5356
|
-
const focusTextBlock = getFocusTextBlock(context), selectionCollapsed = selectionIsCollapsed(context), previousBlock = getPreviousBlock(context);
|
|
5357
|
-
return !focusTextBlock || !selectionCollapsed || !previousBlock ? !1 : isEmptyTextBlock(focusTextBlock.node) && !isPortableTextTextBlock(previousBlock.node) ? {
|
|
5358
|
-
focusTextBlock,
|
|
5359
|
-
previousBlock
|
|
5360
|
-
} : !1;
|
|
5361
|
-
},
|
|
5362
|
-
actions: [(_, {
|
|
5363
|
-
focusTextBlock,
|
|
5364
|
-
previousBlock
|
|
5365
|
-
}) => [{
|
|
5366
|
-
type: "delete",
|
|
5367
|
-
selection: {
|
|
5368
|
-
anchor: {
|
|
5369
|
-
path: focusTextBlock.path,
|
|
5370
|
-
offset: 0
|
|
5371
|
-
},
|
|
5372
|
-
focus: {
|
|
5373
|
-
path: focusTextBlock.path,
|
|
5374
|
-
offset: 0
|
|
5375
|
-
}
|
|
5376
|
-
}
|
|
5377
|
-
}, {
|
|
5378
|
-
type: "select",
|
|
5379
|
-
selection: {
|
|
5380
|
-
anchor: {
|
|
5381
|
-
path: previousBlock.path,
|
|
5382
|
-
offset: 0
|
|
5383
|
-
},
|
|
5384
|
-
focus: {
|
|
5385
|
-
path: previousBlock.path,
|
|
5386
|
-
offset: 0
|
|
5387
|
-
}
|
|
5388
|
-
}
|
|
5389
|
-
}]]
|
|
5390
|
-
}, deletingEmptyTextBlockBeforeBlockObject = {
|
|
5391
|
-
on: "delete forward",
|
|
5392
|
-
guard: ({
|
|
5393
|
-
context
|
|
5394
|
-
}) => {
|
|
5395
|
-
const focusTextBlock = getFocusTextBlock(context), selectionCollapsed = selectionIsCollapsed(context), nextBlock = getNextBlock(context);
|
|
5396
|
-
return !focusTextBlock || !selectionCollapsed || !nextBlock ? !1 : isEmptyTextBlock(focusTextBlock.node) && !isPortableTextTextBlock(nextBlock.node) ? {
|
|
5397
|
-
focusTextBlock,
|
|
5398
|
-
nextBlock
|
|
5399
|
-
} : !1;
|
|
5400
|
-
},
|
|
5401
|
-
actions: [(_, {
|
|
5402
|
-
focusTextBlock,
|
|
5403
|
-
nextBlock
|
|
5404
|
-
}) => [{
|
|
5405
|
-
type: "delete",
|
|
5406
|
-
selection: {
|
|
5407
|
-
anchor: {
|
|
5408
|
-
path: focusTextBlock.path,
|
|
5409
|
-
offset: 0
|
|
5410
|
-
},
|
|
5411
|
-
focus: {
|
|
5412
|
-
path: focusTextBlock.path,
|
|
5413
|
-
offset: 0
|
|
5414
|
-
}
|
|
5415
|
-
}
|
|
5416
|
-
}, {
|
|
5417
|
-
type: "select",
|
|
5418
|
-
selection: {
|
|
5419
|
-
anchor: {
|
|
5420
|
-
path: nextBlock.path,
|
|
5421
|
-
offset: 0
|
|
5422
|
-
},
|
|
5423
|
-
focus: {
|
|
5424
|
-
path: nextBlock.path,
|
|
5425
|
-
offset: 0
|
|
5426
|
-
}
|
|
5427
|
-
}
|
|
5428
|
-
}]]
|
|
5429
|
-
}, coreBlockObjectBehaviors = [breakingVoidBlock, deletingEmptyTextBlockAfterBlockObject, deletingEmptyTextBlockBeforeBlockObject], clearListOnBackspace = {
|
|
5430
|
-
on: "delete backward",
|
|
5431
|
-
guard: ({
|
|
5432
|
-
context
|
|
5433
|
-
}) => {
|
|
5434
|
-
const selectionCollapsed = selectionIsCollapsed(context), focusTextBlock = getFocusTextBlock(context), focusSpan = getFocusSpan(context);
|
|
5435
|
-
return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && context.selection.focus.offset === 0 && focusTextBlock.node.level === 1 ? {
|
|
5436
|
-
focusTextBlock
|
|
5437
|
-
} : !1;
|
|
5438
|
-
},
|
|
5439
|
-
actions: [(_, {
|
|
5440
|
-
focusTextBlock
|
|
5441
|
-
}) => [{
|
|
5442
|
-
type: "unset block",
|
|
5443
|
-
props: ["listItem", "level"],
|
|
5444
|
-
paths: [focusTextBlock.path]
|
|
5445
|
-
}]]
|
|
5446
|
-
}, unindentListOnBackspace = {
|
|
5447
|
-
on: "delete backward",
|
|
5448
|
-
guard: ({
|
|
5449
|
-
context
|
|
5450
|
-
}) => {
|
|
5451
|
-
const selectionCollapsed = selectionIsCollapsed(context), focusTextBlock = getFocusTextBlock(context), focusSpan = getFocusSpan(context);
|
|
5452
|
-
return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && context.selection.focus.offset === 0 && focusTextBlock.node.level !== void 0 && focusTextBlock.node.level > 1 ? {
|
|
5453
|
-
focusTextBlock,
|
|
5454
|
-
level: focusTextBlock.node.level - 1
|
|
5455
|
-
} : !1;
|
|
5456
|
-
},
|
|
5457
|
-
actions: [(_, {
|
|
5458
|
-
focusTextBlock,
|
|
5459
|
-
level
|
|
5460
|
-
}) => [{
|
|
5461
|
-
type: "set block",
|
|
5462
|
-
level,
|
|
5463
|
-
paths: [focusTextBlock.path]
|
|
5464
|
-
}]]
|
|
5465
|
-
}, coreListBehaviors = [clearListOnBackspace, unindentListOnBackspace], softReturn = {
|
|
5466
|
-
on: "insert soft break",
|
|
5467
|
-
actions: [() => [{
|
|
5468
|
-
type: "insert text",
|
|
5469
|
-
text: `
|
|
5470
|
-
`
|
|
5471
|
-
}]]
|
|
5472
|
-
}, coreBehaviors = [softReturn, ...coreBlockObjectBehaviors, ...coreListBehaviors], networkLogic = fromCallback(({
|
|
5488
|
+
const networkLogic = fromCallback(({
|
|
5473
5489
|
sendBack
|
|
5474
5490
|
}) => {
|
|
5475
5491
|
const onlineHandler = () => {
|
|
@@ -5495,7 +5511,7 @@ const breakingVoidBlock = {
|
|
|
5495
5511
|
"assign behaviors": assign({
|
|
5496
5512
|
behaviors: ({
|
|
5497
5513
|
event
|
|
5498
|
-
}) => (assertEvent(event, "update behaviors"),
|
|
5514
|
+
}) => (assertEvent(event, "update behaviors"), event.behaviors)
|
|
5499
5515
|
}),
|
|
5500
5516
|
"assign schema": assign({
|
|
5501
5517
|
schema: ({
|
|
@@ -5589,7 +5605,7 @@ const breakingVoidBlock = {
|
|
|
5589
5605
|
context: ({
|
|
5590
5606
|
input
|
|
5591
5607
|
}) => ({
|
|
5592
|
-
behaviors: input.behaviors
|
|
5608
|
+
behaviors: input.behaviors ?? coreBehaviors,
|
|
5593
5609
|
keyGenerator: input.keyGenerator,
|
|
5594
5610
|
pendingEvents: [],
|
|
5595
5611
|
schema: input.schema
|
|
@@ -6289,6 +6305,8 @@ function useEditor(config) {
|
|
|
6289
6305
|
export {
|
|
6290
6306
|
PortableTextEditable,
|
|
6291
6307
|
PortableTextEditor,
|
|
6308
|
+
coreBehavior,
|
|
6309
|
+
coreBehaviors,
|
|
6292
6310
|
createMarkdownBehaviors,
|
|
6293
6311
|
defineBehavior,
|
|
6294
6312
|
defineSchema,
|