@portabletext/editor 1.24.0 → 1.25.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/lib/_chunks-cjs/behavior.core.cjs +186 -62
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/{selector.is-selection-collapsed.cjs → selector.is-active-style.cjs} +158 -3
- package/lib/_chunks-cjs/selector.is-active-style.cjs.map +1 -0
- package/lib/_chunks-es/behavior.core.js +162 -38
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/{selector.is-selection-collapsed.js → selector.is-active-style.js} +159 -4
- package/lib/_chunks-es/selector.is-active-style.js.map +1 -0
- package/lib/behaviors/index.cjs +27 -27
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.d.cts +1718 -94
- package/lib/behaviors/index.d.ts +1718 -94
- package/lib/behaviors/index.js +1 -1
- package/lib/index.cjs +178 -211
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +8792 -245
- package/lib/index.d.ts +8792 -245
- package/lib/index.js +174 -207
- package/lib/index.js.map +1 -1
- package/lib/selectors/index.cjs +24 -171
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.js +3 -151
- package/lib/selectors/index.js.map +1 -1
- package/package.json +6 -6
- package/src/behavior-actions/behavior.actions.ts +99 -98
- package/src/behaviors/behavior.core.annotations.ts +29 -0
- package/src/behaviors/behavior.core.block-objects.ts +13 -13
- package/src/behaviors/behavior.core.decorators.ts +19 -0
- package/src/behaviors/behavior.core.lists.ts +57 -23
- package/src/behaviors/behavior.core.style.ts +19 -0
- package/src/behaviors/behavior.core.ts +12 -0
- package/src/behaviors/behavior.types.ts +87 -87
- package/src/editor/create-editor.ts +46 -6
- package/src/editor/editor-machine.ts +38 -1
- package/src/editor/plugins/create-with-event-listeners.ts +38 -106
- package/lib/_chunks-cjs/selector.is-selection-collapsed.cjs.map +0 -1
- package/lib/_chunks-es/selector.is-selection-collapsed.js.map +0 -1
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var selector_isActiveStyle = require("./selector.is-active-style.cjs"), types = require("@sanity/types"), util_isEmptyTextBlock = require("./util.is-empty-text-block.cjs");
|
|
3
|
+
function isCustomBehaviorEvent(event) {
|
|
4
|
+
return event.type.startsWith("custom.");
|
|
5
|
+
}
|
|
6
|
+
function raise(event) {
|
|
7
|
+
return {
|
|
8
|
+
type: "raise",
|
|
9
|
+
event
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function defineBehavior(behavior) {
|
|
13
|
+
return behavior;
|
|
14
|
+
}
|
|
15
|
+
const toggleAnnotationOff = {
|
|
16
|
+
on: "annotation.toggle",
|
|
17
|
+
guard: ({
|
|
18
|
+
context,
|
|
19
|
+
event
|
|
20
|
+
}) => selector_isActiveStyle.isActiveAnnotation(event.annotation.name)({
|
|
21
|
+
context
|
|
22
|
+
}),
|
|
23
|
+
actions: [({
|
|
24
|
+
event
|
|
25
|
+
}) => [raise({
|
|
26
|
+
type: "annotation.remove",
|
|
27
|
+
annotation: event.annotation
|
|
28
|
+
})]]
|
|
29
|
+
}, toggleAnnotationOn = {
|
|
30
|
+
on: "annotation.toggle",
|
|
31
|
+
guard: ({
|
|
32
|
+
context,
|
|
33
|
+
event
|
|
34
|
+
}) => !selector_isActiveStyle.isActiveAnnotation(event.annotation.name)({
|
|
35
|
+
context
|
|
36
|
+
}),
|
|
37
|
+
actions: [({
|
|
38
|
+
event
|
|
39
|
+
}) => [raise({
|
|
40
|
+
type: "annotation.add",
|
|
41
|
+
annotation: event.annotation
|
|
42
|
+
})]]
|
|
43
|
+
}, coreAnnotationBehaviors = {
|
|
44
|
+
toggleAnnotationOff,
|
|
45
|
+
toggleAnnotationOn
|
|
46
|
+
}, IS_MAC = typeof window < "u" && /Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent), modifiers = {
|
|
4
47
|
alt: "altKey",
|
|
5
48
|
control: "ctrlKey",
|
|
6
49
|
meta: "metaKey",
|
|
@@ -112,80 +155,68 @@ function toKeyName(name) {
|
|
|
112
155
|
const keyName = name.toLowerCase();
|
|
113
156
|
return aliases[keyName] ?? keyName;
|
|
114
157
|
}
|
|
115
|
-
function isCustomBehaviorEvent(event) {
|
|
116
|
-
return event.type.startsWith("custom.");
|
|
117
|
-
}
|
|
118
|
-
function raise(event) {
|
|
119
|
-
return {
|
|
120
|
-
type: "raise",
|
|
121
|
-
event
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function defineBehavior(behavior) {
|
|
125
|
-
return behavior;
|
|
126
|
-
}
|
|
127
158
|
const arrowDownOnLonelyBlockObject = {
|
|
128
159
|
on: "key.down",
|
|
129
160
|
guard: ({
|
|
130
161
|
context,
|
|
131
162
|
event
|
|
132
163
|
}) => {
|
|
133
|
-
const isArrowDown = isHotkey("ArrowDown", event.keyboardEvent), focusBlockObject =
|
|
164
|
+
const isArrowDown = isHotkey("ArrowDown", event.keyboardEvent), focusBlockObject = selector_isActiveStyle.getFocusBlockObject({
|
|
134
165
|
context
|
|
135
|
-
}), nextBlock =
|
|
166
|
+
}), nextBlock = selector_isActiveStyle.getNextBlock({
|
|
136
167
|
context
|
|
137
168
|
});
|
|
138
169
|
return isArrowDown && focusBlockObject && !nextBlock;
|
|
139
170
|
},
|
|
140
|
-
actions: [() => [{
|
|
171
|
+
actions: [() => [raise({
|
|
141
172
|
type: "insert.text block",
|
|
142
173
|
placement: "after"
|
|
143
|
-
}]]
|
|
174
|
+
})]]
|
|
144
175
|
}, arrowUpOnLonelyBlockObject = {
|
|
145
176
|
on: "key.down",
|
|
146
177
|
guard: ({
|
|
147
178
|
context,
|
|
148
179
|
event
|
|
149
180
|
}) => {
|
|
150
|
-
const isArrowUp = isHotkey("ArrowUp", event.keyboardEvent), focusBlockObject =
|
|
181
|
+
const isArrowUp = isHotkey("ArrowUp", event.keyboardEvent), focusBlockObject = selector_isActiveStyle.getFocusBlockObject({
|
|
151
182
|
context
|
|
152
|
-
}), previousBlock =
|
|
183
|
+
}), previousBlock = selector_isActiveStyle.getPreviousBlock({
|
|
153
184
|
context
|
|
154
185
|
});
|
|
155
186
|
return isArrowUp && focusBlockObject && !previousBlock;
|
|
156
187
|
},
|
|
157
|
-
actions: [() => [{
|
|
188
|
+
actions: [() => [raise({
|
|
158
189
|
type: "insert.text block",
|
|
159
190
|
placement: "before"
|
|
160
|
-
}, {
|
|
191
|
+
}), raise({
|
|
161
192
|
type: "select.previous block"
|
|
162
|
-
}]]
|
|
193
|
+
})]]
|
|
163
194
|
}, breakingBlockObject = {
|
|
164
195
|
on: "insert.break",
|
|
165
196
|
guard: ({
|
|
166
197
|
context
|
|
167
198
|
}) => {
|
|
168
|
-
const focusBlockObject =
|
|
199
|
+
const focusBlockObject = selector_isActiveStyle.getFocusBlockObject({
|
|
169
200
|
context
|
|
170
201
|
});
|
|
171
|
-
return
|
|
202
|
+
return selector_isActiveStyle.isSelectionCollapsed({
|
|
172
203
|
context
|
|
173
204
|
}) && focusBlockObject !== void 0;
|
|
174
205
|
},
|
|
175
|
-
actions: [() => [{
|
|
206
|
+
actions: [() => [raise({
|
|
176
207
|
type: "insert.text block",
|
|
177
208
|
placement: "after"
|
|
178
|
-
}]]
|
|
209
|
+
})]]
|
|
179
210
|
}, deletingEmptyTextBlockAfterBlockObject = {
|
|
180
211
|
on: "delete.backward",
|
|
181
212
|
guard: ({
|
|
182
213
|
context
|
|
183
214
|
}) => {
|
|
184
|
-
const focusTextBlock =
|
|
215
|
+
const focusTextBlock = selector_isActiveStyle.getFocusTextBlock({
|
|
185
216
|
context
|
|
186
|
-
}), selectionCollapsed =
|
|
217
|
+
}), selectionCollapsed = selector_isActiveStyle.isSelectionCollapsed({
|
|
187
218
|
context
|
|
188
|
-
}), previousBlock =
|
|
219
|
+
}), previousBlock = selector_isActiveStyle.getPreviousBlock({
|
|
189
220
|
context
|
|
190
221
|
});
|
|
191
222
|
return !focusTextBlock || !selectionCollapsed || !previousBlock ? !1 : util_isEmptyTextBlock.isEmptyTextBlock(focusTextBlock.node) && !types.isPortableTextTextBlock(previousBlock.node) ? {
|
|
@@ -196,10 +227,10 @@ const arrowDownOnLonelyBlockObject = {
|
|
|
196
227
|
actions: [(_, {
|
|
197
228
|
focusTextBlock,
|
|
198
229
|
previousBlock
|
|
199
|
-
}) => [{
|
|
230
|
+
}) => [raise({
|
|
200
231
|
type: "delete.block",
|
|
201
232
|
blockPath: focusTextBlock.path
|
|
202
|
-
}, {
|
|
233
|
+
}), raise({
|
|
203
234
|
type: "select",
|
|
204
235
|
selection: {
|
|
205
236
|
anchor: {
|
|
@@ -211,17 +242,17 @@ const arrowDownOnLonelyBlockObject = {
|
|
|
211
242
|
offset: 0
|
|
212
243
|
}
|
|
213
244
|
}
|
|
214
|
-
}]]
|
|
245
|
+
})]]
|
|
215
246
|
}, deletingEmptyTextBlockBeforeBlockObject = {
|
|
216
247
|
on: "delete.forward",
|
|
217
248
|
guard: ({
|
|
218
249
|
context
|
|
219
250
|
}) => {
|
|
220
|
-
const focusTextBlock =
|
|
251
|
+
const focusTextBlock = selector_isActiveStyle.getFocusTextBlock({
|
|
221
252
|
context
|
|
222
|
-
}), selectionCollapsed =
|
|
253
|
+
}), selectionCollapsed = selector_isActiveStyle.isSelectionCollapsed({
|
|
223
254
|
context
|
|
224
|
-
}), nextBlock =
|
|
255
|
+
}), nextBlock = selector_isActiveStyle.getNextBlock({
|
|
225
256
|
context
|
|
226
257
|
});
|
|
227
258
|
return !focusTextBlock || !selectionCollapsed || !nextBlock ? !1 : util_isEmptyTextBlock.isEmptyTextBlock(focusTextBlock.node) && !types.isPortableTextTextBlock(nextBlock.node) ? {
|
|
@@ -232,10 +263,10 @@ const arrowDownOnLonelyBlockObject = {
|
|
|
232
263
|
actions: [(_, {
|
|
233
264
|
focusTextBlock,
|
|
234
265
|
nextBlock
|
|
235
|
-
}) => [{
|
|
266
|
+
}) => [raise({
|
|
236
267
|
type: "delete.block",
|
|
237
268
|
blockPath: focusTextBlock.path
|
|
238
|
-
}, {
|
|
269
|
+
}), raise({
|
|
239
270
|
type: "select",
|
|
240
271
|
selection: {
|
|
241
272
|
anchor: {
|
|
@@ -247,7 +278,7 @@ const arrowDownOnLonelyBlockObject = {
|
|
|
247
278
|
offset: 0
|
|
248
279
|
}
|
|
249
280
|
}
|
|
250
|
-
}]]
|
|
281
|
+
})]]
|
|
251
282
|
}, coreBlockObjectBehaviors = {
|
|
252
283
|
arrowDownOnLonelyBlockObject,
|
|
253
284
|
arrowUpOnLonelyBlockObject,
|
|
@@ -255,6 +286,36 @@ const arrowDownOnLonelyBlockObject = {
|
|
|
255
286
|
deletingEmptyTextBlockAfterBlockObject,
|
|
256
287
|
deletingEmptyTextBlockBeforeBlockObject
|
|
257
288
|
}, coreDecoratorBehaviors = {
|
|
289
|
+
toggleDecoratorOff: {
|
|
290
|
+
on: "decorator.toggle",
|
|
291
|
+
guard: ({
|
|
292
|
+
context,
|
|
293
|
+
event
|
|
294
|
+
}) => selector_isActiveStyle.isActiveDecorator(event.decorator)({
|
|
295
|
+
context
|
|
296
|
+
}),
|
|
297
|
+
actions: [({
|
|
298
|
+
event
|
|
299
|
+
}) => [raise({
|
|
300
|
+
type: "decorator.remove",
|
|
301
|
+
decorator: event.decorator
|
|
302
|
+
})]]
|
|
303
|
+
},
|
|
304
|
+
toggleDecoratorOn: {
|
|
305
|
+
on: "decorator.toggle",
|
|
306
|
+
guard: ({
|
|
307
|
+
context,
|
|
308
|
+
event
|
|
309
|
+
}) => !selector_isActiveStyle.isActiveDecorator(event.decorator)({
|
|
310
|
+
context
|
|
311
|
+
}),
|
|
312
|
+
actions: [({
|
|
313
|
+
event
|
|
314
|
+
}) => [raise({
|
|
315
|
+
type: "decorator.add",
|
|
316
|
+
decorator: event.decorator
|
|
317
|
+
})]]
|
|
318
|
+
},
|
|
258
319
|
strongShortcut: {
|
|
259
320
|
on: "key.down",
|
|
260
321
|
guard: ({
|
|
@@ -327,16 +388,44 @@ const arrowDownOnLonelyBlockObject = {
|
|
|
327
388
|
...deserializeEvent,
|
|
328
389
|
dataTransfer: event.dataTransfer
|
|
329
390
|
})]]
|
|
330
|
-
}, MAX_LIST_LEVEL = 10,
|
|
391
|
+
}, MAX_LIST_LEVEL = 10, toggleListItemOff = {
|
|
392
|
+
on: "list item.toggle",
|
|
393
|
+
guard: ({
|
|
394
|
+
context,
|
|
395
|
+
event
|
|
396
|
+
}) => selector_isActiveStyle.isActiveListItem(event.listItem)({
|
|
397
|
+
context
|
|
398
|
+
}),
|
|
399
|
+
actions: [({
|
|
400
|
+
event
|
|
401
|
+
}) => [raise({
|
|
402
|
+
type: "list item.remove",
|
|
403
|
+
listItem: event.listItem
|
|
404
|
+
})]]
|
|
405
|
+
}, toggleListItemOn = {
|
|
406
|
+
on: "list item.toggle",
|
|
407
|
+
guard: ({
|
|
408
|
+
context,
|
|
409
|
+
event
|
|
410
|
+
}) => !selector_isActiveStyle.isActiveListItem(event.listItem)({
|
|
411
|
+
context
|
|
412
|
+
}),
|
|
413
|
+
actions: [({
|
|
414
|
+
event
|
|
415
|
+
}) => [raise({
|
|
416
|
+
type: "list item.add",
|
|
417
|
+
listItem: event.listItem
|
|
418
|
+
})]]
|
|
419
|
+
}, clearListOnBackspace = {
|
|
331
420
|
on: "delete.backward",
|
|
332
421
|
guard: ({
|
|
333
422
|
context
|
|
334
423
|
}) => {
|
|
335
|
-
const selectionCollapsed =
|
|
424
|
+
const selectionCollapsed = selector_isActiveStyle.isSelectionCollapsed({
|
|
336
425
|
context
|
|
337
|
-
}), focusTextBlock =
|
|
426
|
+
}), focusTextBlock = selector_isActiveStyle.getFocusTextBlock({
|
|
338
427
|
context
|
|
339
|
-
}), focusSpan =
|
|
428
|
+
}), focusSpan = selector_isActiveStyle.getFocusSpan({
|
|
340
429
|
context
|
|
341
430
|
});
|
|
342
431
|
return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && context.selection?.focus.offset === 0 && focusTextBlock.node.level === 1 ? {
|
|
@@ -345,21 +434,21 @@ const arrowDownOnLonelyBlockObject = {
|
|
|
345
434
|
},
|
|
346
435
|
actions: [(_, {
|
|
347
436
|
focusTextBlock
|
|
348
|
-
}) => [{
|
|
437
|
+
}) => [raise({
|
|
349
438
|
type: "text block.unset",
|
|
350
439
|
props: ["listItem", "level"],
|
|
351
440
|
at: focusTextBlock.path
|
|
352
|
-
}]]
|
|
441
|
+
})]]
|
|
353
442
|
}, unindentListOnBackspace = {
|
|
354
443
|
on: "delete.backward",
|
|
355
444
|
guard: ({
|
|
356
445
|
context
|
|
357
446
|
}) => {
|
|
358
|
-
const selectionCollapsed =
|
|
447
|
+
const selectionCollapsed = selector_isActiveStyle.isSelectionCollapsed({
|
|
359
448
|
context
|
|
360
|
-
}), focusTextBlock =
|
|
449
|
+
}), focusTextBlock = selector_isActiveStyle.getFocusTextBlock({
|
|
361
450
|
context
|
|
362
|
-
}), focusSpan =
|
|
451
|
+
}), focusSpan = selector_isActiveStyle.getFocusSpan({
|
|
363
452
|
context
|
|
364
453
|
});
|
|
365
454
|
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 ? {
|
|
@@ -370,19 +459,19 @@ const arrowDownOnLonelyBlockObject = {
|
|
|
370
459
|
actions: [(_, {
|
|
371
460
|
focusTextBlock,
|
|
372
461
|
level
|
|
373
|
-
}) => [{
|
|
462
|
+
}) => [raise({
|
|
374
463
|
type: "text block.set",
|
|
375
464
|
level,
|
|
376
465
|
at: focusTextBlock.path
|
|
377
|
-
}]]
|
|
466
|
+
})]]
|
|
378
467
|
}, clearListOnEnter = {
|
|
379
468
|
on: "insert.break",
|
|
380
469
|
guard: ({
|
|
381
470
|
context
|
|
382
471
|
}) => {
|
|
383
|
-
const selectionCollapsed =
|
|
472
|
+
const selectionCollapsed = selector_isActiveStyle.isSelectionCollapsed({
|
|
384
473
|
context
|
|
385
|
-
}), focusListBlock =
|
|
474
|
+
}), focusListBlock = selector_isActiveStyle.getFocusListBlock({
|
|
386
475
|
context
|
|
387
476
|
});
|
|
388
477
|
return !selectionCollapsed || !focusListBlock || !util_isEmptyTextBlock.isEmptyTextBlock(focusListBlock.node) ? !1 : {
|
|
@@ -391,11 +480,11 @@ const arrowDownOnLonelyBlockObject = {
|
|
|
391
480
|
},
|
|
392
481
|
actions: [(_, {
|
|
393
482
|
focusListBlock
|
|
394
|
-
}) => [{
|
|
483
|
+
}) => [raise({
|
|
395
484
|
type: "text block.unset",
|
|
396
485
|
props: ["listItem", "level"],
|
|
397
486
|
at: focusListBlock.path
|
|
398
|
-
}]]
|
|
487
|
+
})]]
|
|
399
488
|
}, indentListOnTab = {
|
|
400
489
|
on: "key.down",
|
|
401
490
|
guard: ({
|
|
@@ -404,9 +493,9 @@ const arrowDownOnLonelyBlockObject = {
|
|
|
404
493
|
}) => {
|
|
405
494
|
if (!isHotkey("Tab", event.keyboardEvent))
|
|
406
495
|
return !1;
|
|
407
|
-
const selectedBlocks =
|
|
496
|
+
const selectedBlocks = selector_isActiveStyle.getSelectedBlocks({
|
|
408
497
|
context
|
|
409
|
-
}), guards =
|
|
498
|
+
}), guards = selector_isActiveStyle.createGuards(context), selectedListBlocks = selectedBlocks.flatMap((block) => guards.isListBlock(block.node) ? [{
|
|
410
499
|
node: block.node,
|
|
411
500
|
path: block.path
|
|
412
501
|
}] : []);
|
|
@@ -416,7 +505,7 @@ const arrowDownOnLonelyBlockObject = {
|
|
|
416
505
|
},
|
|
417
506
|
actions: [(_, {
|
|
418
507
|
selectedListBlocks
|
|
419
|
-
}) => selectedListBlocks.map((selectedListBlock) => ({
|
|
508
|
+
}) => selectedListBlocks.map((selectedListBlock) => raise({
|
|
420
509
|
type: "text block.set",
|
|
421
510
|
level: Math.min(MAX_LIST_LEVEL, Math.max(1, selectedListBlock.node.level + 1)),
|
|
422
511
|
at: selectedListBlock.path
|
|
@@ -429,9 +518,9 @@ const arrowDownOnLonelyBlockObject = {
|
|
|
429
518
|
}) => {
|
|
430
519
|
if (!isHotkey("Shift+Tab", event.keyboardEvent))
|
|
431
520
|
return !1;
|
|
432
|
-
const selectedBlocks =
|
|
521
|
+
const selectedBlocks = selector_isActiveStyle.getSelectedBlocks({
|
|
433
522
|
context
|
|
434
|
-
}), guards =
|
|
523
|
+
}), guards = selector_isActiveStyle.createGuards(context), selectedListBlocks = selectedBlocks.flatMap((block) => guards.isListBlock(block.node) ? [{
|
|
435
524
|
node: block.node,
|
|
436
525
|
path: block.path
|
|
437
526
|
}] : []);
|
|
@@ -441,12 +530,14 @@ const arrowDownOnLonelyBlockObject = {
|
|
|
441
530
|
},
|
|
442
531
|
actions: [(_, {
|
|
443
532
|
selectedListBlocks
|
|
444
|
-
}) => selectedListBlocks.map((selectedListBlock) => ({
|
|
533
|
+
}) => selectedListBlocks.map((selectedListBlock) => raise({
|
|
445
534
|
type: "text block.set",
|
|
446
535
|
level: Math.min(MAX_LIST_LEVEL, Math.max(1, selectedListBlock.node.level - 1)),
|
|
447
536
|
at: selectedListBlock.path
|
|
448
537
|
}))]
|
|
449
538
|
}, coreListBehaviors = {
|
|
539
|
+
toggleListItemOff,
|
|
540
|
+
toggleListItemOn,
|
|
450
541
|
clearListOnBackspace,
|
|
451
542
|
unindentListOnBackspace,
|
|
452
543
|
clearListOnEnter,
|
|
@@ -485,6 +576,37 @@ const arrowDownOnLonelyBlockObject = {
|
|
|
485
576
|
mimeType: event.mimeType
|
|
486
577
|
})]]
|
|
487
578
|
}
|
|
579
|
+
}, toggleStyleOff = {
|
|
580
|
+
on: "style.toggle",
|
|
581
|
+
guard: ({
|
|
582
|
+
context,
|
|
583
|
+
event
|
|
584
|
+
}) => selector_isActiveStyle.isActiveStyle(event.style)({
|
|
585
|
+
context
|
|
586
|
+
}),
|
|
587
|
+
actions: [({
|
|
588
|
+
event
|
|
589
|
+
}) => [raise({
|
|
590
|
+
type: "style.remove",
|
|
591
|
+
style: event.style
|
|
592
|
+
})]]
|
|
593
|
+
}, toggleStyleOn = {
|
|
594
|
+
on: "style.toggle",
|
|
595
|
+
guard: ({
|
|
596
|
+
context,
|
|
597
|
+
event
|
|
598
|
+
}) => !selector_isActiveStyle.isActiveStyle(event.style)({
|
|
599
|
+
context
|
|
600
|
+
}),
|
|
601
|
+
actions: [({
|
|
602
|
+
event
|
|
603
|
+
}) => [raise({
|
|
604
|
+
type: "style.add",
|
|
605
|
+
style: event.style
|
|
606
|
+
})]]
|
|
607
|
+
}, coreStyleBehaviors = {
|
|
608
|
+
toggleStyleOff,
|
|
609
|
+
toggleStyleOn
|
|
488
610
|
}, softReturn = {
|
|
489
611
|
on: "insert.soft break",
|
|
490
612
|
actions: [() => [{
|
|
@@ -492,13 +614,15 @@ const arrowDownOnLonelyBlockObject = {
|
|
|
492
614
|
text: `
|
|
493
615
|
`
|
|
494
616
|
}]]
|
|
495
|
-
}, coreBehaviors = [softReturn, coreDecoratorBehaviors.strongShortcut, coreDecoratorBehaviors.emShortcut, coreDecoratorBehaviors.underlineShortcut, coreDecoratorBehaviors.codeShortcut, coreDeserializeBehavior, coreBlockObjectBehaviors.arrowDownOnLonelyBlockObject, coreBlockObjectBehaviors.arrowUpOnLonelyBlockObject, coreBlockObjectBehaviors.breakingBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockAfterBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockBeforeBlockObject, coreListBehaviors.clearListOnBackspace, coreListBehaviors.unindentListOnBackspace, coreListBehaviors.clearListOnEnter, coreListBehaviors.indentListOnTab, coreListBehaviors.unindentListOnShiftTab, coreSerializeBehaviors.serialize, coreSerializeBehaviors["serialization.success"]], coreBehavior = {
|
|
617
|
+
}, coreBehaviors = [softReturn, coreAnnotationBehaviors.toggleAnnotationOff, coreAnnotationBehaviors.toggleAnnotationOn, coreDecoratorBehaviors.toggleDecoratorOff, coreDecoratorBehaviors.toggleDecoratorOn, coreDecoratorBehaviors.strongShortcut, coreDecoratorBehaviors.emShortcut, coreDecoratorBehaviors.underlineShortcut, coreDecoratorBehaviors.codeShortcut, coreDeserializeBehavior, coreBlockObjectBehaviors.arrowDownOnLonelyBlockObject, coreBlockObjectBehaviors.arrowUpOnLonelyBlockObject, coreBlockObjectBehaviors.breakingBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockAfterBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockBeforeBlockObject, coreListBehaviors.toggleListItemOff, coreListBehaviors.toggleListItemOn, coreListBehaviors.clearListOnBackspace, coreListBehaviors.unindentListOnBackspace, coreListBehaviors.clearListOnEnter, coreListBehaviors.indentListOnTab, coreListBehaviors.unindentListOnShiftTab, coreSerializeBehaviors.serialize, coreSerializeBehaviors["serialization.success"], coreStyleBehaviors.toggleStyleOff, coreStyleBehaviors.toggleStyleOn], coreBehavior = {
|
|
496
618
|
softReturn,
|
|
619
|
+
annotation: coreAnnotationBehaviors,
|
|
497
620
|
decorators: coreDecoratorBehaviors,
|
|
498
621
|
deserialize: coreDeserializeBehavior,
|
|
499
622
|
blockObjects: coreBlockObjectBehaviors,
|
|
500
623
|
lists: coreListBehaviors,
|
|
501
|
-
...coreSerializeBehaviors
|
|
624
|
+
...coreSerializeBehaviors,
|
|
625
|
+
style: coreSerializeBehaviors
|
|
502
626
|
};
|
|
503
627
|
exports.coreBehavior = coreBehavior;
|
|
504
628
|
exports.coreBehaviors = coreBehaviors;
|