@nerd-bible/wordgard 0.0.0-beta3

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.
@@ -0,0 +1,808 @@
1
+ import { Wordgard } from 'wordgard/editor';
2
+ import { Transaction, GardState } from 'wordgard/state';
3
+ import { PhraseSet } from 'wordgard/phrases';
4
+ import { Mark, Plot, Node, Schema, Pos, ChangeSet } from 'wordgard/doc';
5
+
6
+ /**
7
+ A command is a function that takes an editor and an additional
8
+ parameter, and either...
9
+
10
+ - returns `false` to indicate that it does not apply to the
11
+ current editor state
12
+
13
+ - performs its action as a side effect and returns `true`
14
+
15
+ - returns a {@link state.Transaction.Spec transaction spec} that
16
+ should be dispatched as its effect
17
+
18
+ This formulation is chosen to cover both side-effecting commands
19
+ (whose effect may not even directly affect the editor—a command
20
+ may just open a dialog or change some editor-external state) _and_
21
+ {@link Command.Pure commands} implemented as pure functions from
22
+ state to transaction.
23
+
24
+ Extensions can register additional handlers for a command, which
25
+ will be called in order of precedence (until one returns true)
26
+ when the command is {@link Command.dispatch dispatched}.
27
+ Commands are recognized by function identity. So, for example, the
28
+ `enter` command is both the tag used to indicate invocation of an
29
+ enter press and the function that implements the default behavior
30
+ for this action.
31
+ */
32
+ type Command<Param = null> = (target: Wordgard, param: Param) => boolean | Transaction.Spec;
33
+ declare namespace Command {
34
+ /**
35
+ `Command.Pure` is a subtype of `Command` that relies only on the
36
+ editor state, and performs no imperative effects. When
37
+ implementing such a command function, it can be useful to tag it
38
+ with this type, so that it can be invoked without a full editor
39
+ component for testing or for use in a context where there is no
40
+ editor.
41
+
42
+ Note that invoking a command function directly will not activate
43
+ custom {@link Command.handler handlers}.
44
+ */
45
+ type Pure<Param = null> = (target: {
46
+ state: GardState;
47
+ }, param: Param) => false | Transaction.Spec;
48
+ /**
49
+ Create an extension that adds a handler for the given {@link
50
+ Command command}.
51
+ */
52
+ function handler<Param>(command: Command<Param>, handler: Command<Param>): GardState.Extension;
53
+ /**
54
+ Bind a command with a parameter. The only thing you can do with
55
+ a bound command is to {@link Command.dispatch dispatch} it.
56
+ */
57
+ function bind<Param>(command: Command<Param>, param: Param): Command.Bound;
58
+ /**
59
+ Opaque type used for {@link Command.bind bound} commands.
60
+ */
61
+ type Bound = {
62
+ readonly tag: unique symbol;
63
+ };
64
+ /**
65
+ Apply a command to the given editor view. When passing a
66
+ non-{@link Command.bind bound} command with a parameter, the
67
+ parameter has to be passed as second argument.
68
+ */
69
+ function dispatch(wg: Wordgard, command: Command<null> | Command.Bound): boolean;
70
+ function dispatch<Param>(wg: Wordgard, command: Command<Param>, param: Param): boolean;
71
+ }
72
+
73
+ declare namespace Menu {
74
+ /**
75
+ Editor menus are structured as trees, with item groups and
76
+ submenus as internal nodes, and buttons and custom controls as
77
+ leaf nodes.
78
+ */
79
+ type Item = Group | Submenu | Button | CustomControl;
80
+ namespace Item {
81
+ /**
82
+ Generic configuration fields supported by all menu items.
83
+ */
84
+ interface Spec {
85
+ /**
86
+ When given and returning false, this item should be hidden
87
+ from the menu. Should be used sparingly, to avoid the menu
88
+ constantly flickering and changing size as the user is
89
+ editing.
90
+ */
91
+ select?: (state: GardState) => boolean;
92
+ /**
93
+ When given and returning false, this item is disabled, which
94
+ means it looks faded and cannot be interacted with.
95
+ */
96
+ enable?: (state: GardState) => boolean;
97
+ /**
98
+ By default, state predicates (`select`, `enable`, and `active`)
99
+ are re-checked whenever the document or selection changes. If an
100
+ item is sensitive to other aspects of the state, provide a test
101
+ here that returns `true` for transactions that might affect the
102
+ item state.
103
+ */
104
+ updateFor?: (tr: Transaction) => boolean;
105
+ /**
106
+ The item's parent. See {@link Menu.resolve} for information
107
+ on how menus are linked up.
108
+ */
109
+ parent?: Group | Submenu;
110
+ /**
111
+ Determines the order of elements in the parent. Should be a
112
+ number between 0 and 100. Defaults to 100.
113
+ */
114
+ rank?: number;
115
+ /**
116
+ A description to associate with the item, used for hover
117
+ tooltips and screen-reader text. If the item has a textual
118
+ label, this will default to that label when not given.
119
+ */
120
+ description?: PhraseSet.Ref | string;
121
+ }
122
+ /**
123
+ Base class for menu items, storing the fields specified in
124
+ {@link Menu.Item.Spec}.
125
+ */
126
+ class Base {
127
+ select: ((state: GardState) => boolean) | undefined;
128
+ enable: ((state: GardState) => boolean) | undefined;
129
+ updateFor: ((tr: Transaction) => boolean) | undefined;
130
+ parent: Group | Submenu | undefined;
131
+ rank: number;
132
+ description: PhraseSet.Ref | string | undefined;
133
+ /**
134
+ Menu items can be used as editor extensions to include them
135
+ in a configuration.
136
+ */
137
+ extension: GardState.Extension;
138
+ }
139
+ /**
140
+ The facet used to add menu items to a configuration. Used by
141
+ the items' extensions to register them, and by menu
142
+ implementations to find available items.
143
+ */
144
+ const source: GardState.Facet<Item, readonly Item[]>;
145
+ /**
146
+ A resolved menu consists of buttons, custom controls,
147
+ submenus, and spacers, which are represented by the string
148
+ literal `"|"`.
149
+ */
150
+ type Resolved = Button | CustomControl | "|" | Submenu.Resolved;
151
+ }
152
+ /**
153
+ Labels are used by buttons and submenus to determine what they
154
+ look like. They may either be textual (a string or reference to
155
+ a phrase), or an icon, which is expressed an SVG path string
156
+ that draws the icon inside a 100-by-100 space. The `directional`
157
+ flag indicates that the icon should be mirrored vertically in a
158
+ right-to-left editor.
159
+ */
160
+ type Label = string | PhraseSet.Ref | {
161
+ icon: string;
162
+ directional?: boolean;
163
+ };
164
+ /**
165
+ A menu button runs a command when activated. See the {@link
166
+ Menu.Button.Spec spec type} for the meaning of the fields.
167
+ */
168
+ class Button extends Item.Base {
169
+ /**
170
+ The configuration object used to create this button.
171
+ */
172
+ readonly spec: Button.Spec;
173
+ label: Label;
174
+ run: Command.Bound | Command;
175
+ active: ((state: GardState) => boolean) | undefined;
176
+ private constructor();
177
+ /**
178
+ Define a menu button.
179
+ */
180
+ static define(spec: Button.Spec): Button;
181
+ }
182
+ namespace Button {
183
+ interface Spec extends Item.Spec {
184
+ /**
185
+ The command to run when the user activates the button.
186
+ */
187
+ run: Command.Bound | Command;
188
+ /**
189
+ When this returns true, the button is highlighted as active.
190
+ This can be used to show, for example, that a mark is active
191
+ at the cursor, or that a block type matches the block around
192
+ the current selection. Also used to automatically select a
193
+ label for a {@link Menu.Submenu submenu}.
194
+ */
195
+ active?: (state: GardState) => boolean;
196
+ /**
197
+ The label to show on this button.
198
+ */
199
+ label: Label;
200
+ }
201
+ /**
202
+ Creates a menu button that toggles an inline mark via {@link
203
+ Menu.Button.toggleMark}, and is shown as active when either
204
+ that mark is part of the marks associated with the current
205
+ cursor, or the selection covers only content with that mark.
206
+ */
207
+ function toggleMark(config: {
208
+ mark: Mark;
209
+ parent?: Menu.Group | Menu.Submenu;
210
+ rank?: number;
211
+ description?: PhraseSet.Ref;
212
+ label: Menu.Label;
213
+ }): Button;
214
+ }
215
+ /**
216
+ Custom controls are similar to buttons, in that they can be part
217
+ of the menu and receive focus through menu navigation, but they
218
+ manage their own DOM. This can be used for elements like color
219
+ pickers that should be displayed inside of the menu but support
220
+ user interaction more complex than a button.
221
+ */
222
+ class CustomControl extends Item.Base {
223
+ /**
224
+ The configuration object used to create this control.
225
+ */
226
+ readonly spec: CustomControl.Spec;
227
+ /**
228
+ See {@link Menu.CustomControl.Spec.render}.
229
+ */
230
+ render: (wg: Wordgard, done: () => void) => {
231
+ dom: HTMLElement;
232
+ focus?: HTMLElement;
233
+ };
234
+ /**
235
+ See {@link Menu.CustomControl.Spec.setEnabled}.
236
+ */
237
+ setEnabled: ((dom: Element, enabled: boolean) => void) | undefined;
238
+ private constructor();
239
+ /**
240
+ Define a custom menu item.
241
+ */
242
+ static define(spec: CustomControl.Spec): CustomControl;
243
+ }
244
+ namespace CustomControl {
245
+ interface Spec extends Item.Spec {
246
+ /**
247
+ The function that renders the actual control. The `dom`
248
+ property on the returned object will be displayed in the
249
+ menu. If `focus` is provided, that is used as the element to
250
+ put focus on. If not, `dom` is used.
251
+
252
+ The control should call the `done` function when it decides
253
+ it is closed or activated, so that any submenu above it
254
+ knows to close, and focus can be moved back to the editor if
255
+ appropriate.
256
+ */
257
+ render: (wg: Wordgard, done: () => void) => {
258
+ dom: HTMLElement;
259
+ focus?: HTMLElement;
260
+ };
261
+ /**
262
+ If the control supports {@link Menu.Item.Spec.enable
263
+ disabling}, this function will be called when the enabled
264
+ state changes, and should update the control to show this.
265
+ */
266
+ setEnabled?: (focus: Element, enabled: boolean) => void;
267
+ }
268
+ }
269
+ /**
270
+ Groups are used to organize sets of menu items together. The
271
+ {@link Menu.Group.top top-level menu} is a group, but groups
272
+ may appear at any level, so that items with similar roles can
273
+ attach themselves to them in order to appear next to each other.
274
+
275
+ See the {@link Menu.Group.Spec spec type} for the meaning of the
276
+ class's fields.
277
+ */
278
+ class Group {
279
+ /**
280
+ The configuration object used to create this group.
281
+ */
282
+ readonly spec: Group.Spec;
283
+ margin: boolean;
284
+ parent: Group | Submenu | undefined;
285
+ rank: number;
286
+ content: readonly (Item | "...")[] | undefined;
287
+ overflow: {
288
+ at: number;
289
+ wrap?: Submenu;
290
+ } | undefined;
291
+ /**
292
+ Menu groups count as extensions.
293
+ */
294
+ extension: GardState.Extension;
295
+ private constructor();
296
+ /**
297
+ Define a menu group.
298
+ */
299
+ static define(spec?: Group.Spec): Group;
300
+ /**
301
+ Create a template for this group.
302
+ */
303
+ template(...content: (Template | Item | "...")[]): Template;
304
+ }
305
+ namespace Group {
306
+ /**
307
+ Options used to configure a menu group.
308
+ */
309
+ interface Spec {
310
+ /**
311
+ When set to true, leave a bit of space between this group
312
+ and adjacent items.
313
+ */
314
+ margin?: boolean;
315
+ /**
316
+ The group's parent item, if any.
317
+ */
318
+ parent?: Group | Submenu;
319
+ /**
320
+ The group's rank within its parent.
321
+ */
322
+ rank?: number;
323
+ /**
324
+ Default content for this group. Usually you don't need this,
325
+ as you let parent links from the content items determine
326
+ what goes in the group. See the {@link Menu.resolve menu
327
+ resolution} system.
328
+ */
329
+ content?: readonly (Item | "...")[];
330
+ /**
331
+ If given when, during resolution, the group contains more
332
+ than `at` items, wrap items `at - 1` and up in a submenu.
333
+ You may optionally provide submenu object to specify the
334
+ look of the submenu, or let it default to showing three
335
+ vertical dots.
336
+ */
337
+ overflow?: {
338
+ at: number;
339
+ wrap?: Submenu;
340
+ };
341
+ }
342
+ /**
343
+ The top-level menu. When you don't provide a custom menu
344
+ template, this is the starting point from which the menu will
345
+ be resolved. Parent of most other groups.
346
+ */
347
+ const top: Group;
348
+ /**
349
+ Editing commands. Holds items like the history undo/redo
350
+ buttons.
351
+ */
352
+ const commands: Group;
353
+ /**
354
+ Inline style items. Will, by default, contain buttons to
355
+ create emphasized text, links, and so on.
356
+ */
357
+ const inline: Group;
358
+ /**
359
+ Group for block-related items. Holds things like list toggles
360
+ and text alignment.
361
+ */
362
+ const block: Group;
363
+ /**
364
+ Group for inserting elements into the document, such as images
365
+ or tables.
366
+ */
367
+ const insert: Group;
368
+ }
369
+ /**
370
+ A submenu is a menu item that, when activated, shows the menu
371
+ items that are nested under it. See the {@link Menu.Submenu.spec
372
+ spec type} for the meaning of the class fields.
373
+ */
374
+ class Submenu extends Item.Base {
375
+ /**
376
+ The configuration object used to define this submenu.
377
+ */
378
+ readonly spec: Submenu.Spec;
379
+ label: Label | undefined;
380
+ defaultLabel: Label | undefined;
381
+ arrow: boolean;
382
+ width: number | undefined;
383
+ content: readonly (Item | "...")[] | undefined;
384
+ private constructor();
385
+ /**
386
+ Define a submenu.
387
+ */
388
+ static define(spec: Submenu.Spec): Submenu;
389
+ /**
390
+ Create a template item for this submenu.
391
+ */
392
+ template(...content: (Template | Item | "...")[]): Template;
393
+ }
394
+ namespace Submenu {
395
+ /**
396
+ The options that can be passed to a submenu.
397
+ */
398
+ interface Spec extends Item.Spec {
399
+ /**
400
+ The label to show for the submenu. When not given, the
401
+ submenu will look for the first {@link
402
+ Menu.Button.Spec.active active} item in its children, and
403
+ use that child's label, or fall back to `defaultLabel`.
404
+ */
405
+ label?: Label;
406
+ /**
407
+ Fallback label when no regular label is given and there are
408
+ no active children.
409
+ */
410
+ defaultLabel?: Label;
411
+ /**
412
+ Whether to show an arrow on the submenu button to indicate
413
+ that it can be expanded. Defaults to true.
414
+ */
415
+ arrow?: boolean;
416
+ /**
417
+ A base with for the submenu button, in CSS `ch` units. Can
418
+ be useful when the menu uses a dynamic textual label, and
419
+ you want to prevent it from changing size as its label
420
+ changes.
421
+ */
422
+ width?: number;
423
+ /**
424
+ An optional default content. See the {@link Menu.resolve
425
+ resolution system}.
426
+ */
427
+ content?: readonly (Item | "...")[];
428
+ }
429
+ /**
430
+ A resolved submenu, part of the output of {@link
431
+ Menu.resolve}.
432
+ */
433
+ class Resolved {
434
+ /**
435
+ The submenu item.
436
+ */
437
+ readonly item: Submenu;
438
+ /**
439
+ The items inside the submenu.
440
+ */
441
+ readonly content: readonly Item.Resolved[];
442
+ private constructor();
443
+ }
444
+ /**
445
+ The submenu to select textblock type. Used to switch between,
446
+ for example, regular paragraphs and headings
447
+ */
448
+ const textblockStyle: Submenu;
449
+ }
450
+ /**
451
+ Templates are used to explicitly choose (part of) your menu
452
+ structure, rather than letting the resolution algorithm build
453
+ one from your configuration. See {@link Menu.resolve}, {@link
454
+ Menu.Group.template `Group.template`}, and {@link
455
+ Menu.Submenu.template `Submenu.template`}.
456
+ */
457
+ class Template {
458
+ private tag;
459
+ private constructor();
460
+ }
461
+ /**
462
+ Given a set of menu items and optionally a template, this
463
+ function will resolve a concrete menu tree. To do this, it goes
464
+ through the template (which defaults to just the {@link
465
+ Menu.Group.top top group}), filling in open spaces (represented
466
+ as the string literal `"..."`) with any items provided that have
467
+ the group or submenu as parent.
468
+
469
+ The idea is to combine a top-down (the template) and bottom-up
470
+ (the items, which typically come from an editor {@link
471
+ Menu.Item.source configuration}) in a way that allows the user
472
+ to figure out a balance between manually specifying their menu
473
+ and just using whatever is in the configuration.
474
+
475
+ Items that are used explicitly in a template will not be used
476
+ again implicitly. Items included in the `suppress` parameter
477
+ will be ignored.
478
+
479
+ When a submenu or group specifies default content, this will
480
+ only be used when the template does not specify its own content
481
+ for the item.
482
+ */
483
+ function resolve(items: readonly Item[], template?: Template | readonly Template[], suppress?: readonly Item[]): readonly Item.Resolved[];
484
+ }
485
+
486
+ /**
487
+ This command handles text input. To selectively override the
488
+ behavior of text input, provide a handler that, when the
489
+ conditions that it requires apply, handles the input and returns
490
+ true. `userEvent` will generally be one of `"input.type"`,
491
+ `"input.type.compose"` (text inserted as part as a composition),
492
+ or `"input.type.compose.start"` (initial text created by a started
493
+ composition).
494
+ */
495
+ declare const insertText: Command.Pure<{
496
+ from: number;
497
+ to: number;
498
+ insert: string;
499
+ userEvent: string;
500
+ }>;
501
+ /**
502
+ Command to insert a line break. The default handler will, if the
503
+ schema defines a {@link Node.Role.LineBreak line break} node and
504
+ the selection's parent node allows that, insert such a node.
505
+ Otherwise, in nodes marked as
506
+ {@link Plot.Spec.preserveWhitespace whitespace-preserving}, this
507
+ will insert a line break.
508
+ */
509
+ declare const insertLineBreak: Command.Pure;
510
+ /**
511
+ The command that handles enter presses. The default handler will,
512
+ if the selection is not in an inline context, insert an empty
513
+ default textblock in its position. Otherwise it first tries {@link
514
+ enterInCode}, then {@link liftEmptyBlock}, and finally {@link
515
+ splitTextblock}.
516
+ */
517
+ declare const enter: Command.Pure;
518
+ /**
519
+ Delete the selection, or the unit after or before the selection.
520
+ If that unit is the start or end of a textblock, this will try to
521
+ join that textblock to the next one. Otherwise, if it is a
522
+ character or leaf node, that is deleted. If none of that is
523
+ possible and the cursor is in an empty textblock, this will delete
524
+ the textblock.
525
+
526
+ When deleting backward at the start of a list item that has a
527
+ sibling before it, this command will try to join those list items.
528
+ */
529
+ declare const deleteUnit: Command.Pure<"forward" | "backward">;
530
+ /**
531
+ Delete the selection, or the word next to it. Will behave like
532
+ {@link deleteUnit}, except that, when deleting text, it will
533
+ delete an entire word.
534
+ */
535
+ declare const deleteWord: Command.Pure<"forward" | "backward">;
536
+ /**
537
+ Delete to the end or start of the line. Stops at line wrapping
538
+ points.
539
+ */
540
+ declare const deleteToLineEnd: Command<"forward" | "backward">;
541
+ /**
542
+ Delete the selection, or if that is empty, the line around the
543
+ cursor.
544
+ */
545
+ declare const deleteLine: Command;
546
+ /**
547
+ Swap the characters before and after the cursor.
548
+ */
549
+ declare const transposeChars: Command.Pure;
550
+ /**
551
+ Set the type of the textblock(s) around the selection to the given
552
+ tag.
553
+ */
554
+ declare const setTextblockType: Command.Pure<Plot.Tag>;
555
+ /**
556
+ Try to unwrap blocks around the selection. The second argument, if
557
+ given, indicates what kind of wrapping plots may be removed.
558
+ Returns null when no unwrapping is possible.
559
+ */
560
+ declare const unwrapBlock: Command.Pure<Node.Query | null>;
561
+ /**
562
+ Try to wrap selected textblocks in the given wrapper. Will return
563
+ null if no wrapping is possible.
564
+ */
565
+ declare const wrapBlock: Command.Pure<Plot.Tag>;
566
+ /**
567
+ If the selection is in a block of the given type, unwap it.
568
+ Otherwise, try to wrap the selected blocks in such a tag.
569
+ */
570
+ declare const toggleBlock: Command.Pure<Plot.Tag>;
571
+ /**
572
+ Toggle the given mark. If there is no selection, it is added to
573
+ the cursor's active marks, or removed if it is already in there.
574
+ Otherwise, if any selected content allows for the mark to be
575
+ added, it is added. If not, remove the mark from the selection.
576
+ */
577
+ declare const toggleMark: Command.Pure<Mark>;
578
+ /**
579
+ Toggle emphasis. The default implementation uses the {@link
580
+ Emphasis} mark.
581
+ */
582
+ declare const toggleEmphasis: Command.Pure;
583
+ /**
584
+ Toggle strong emphasis. The default implementation uses the {@link
585
+ Strong} mark.
586
+ */
587
+ declare const toggleStrong: Command.Pure;
588
+ /**
589
+ Toggle underlining. The default implementation uses the {@link
590
+ Underline} mark.
591
+ */
592
+ declare const toggleUnderline: Command.Pure;
593
+ /**
594
+ Set the selected textblocks to the given alignment. `"left"` and
595
+ `"right"` will be normalized to `"start"` or `"end"` depending on
596
+ the editor's text direction. The default implementation uses the
597
+ {@link Alignment} mark.
598
+ */
599
+ declare const setAlignment: Command.Pure<null | "start" | "end" | "center" | "left" | "right">;
600
+ /**
601
+ Set the text direction for the selected textblocks. `null` will
602
+ remove an explicit direction mark, defaulting the blocks back to
603
+ the editor's base direction. The default implementation uses the
604
+ {@link Direction} mark.
605
+ */
606
+ declare const setDirection: Command.Pure<null | "ltr" | "rtl" | "auto">;
607
+ /**
608
+ Toggle list wrapping with the given list tag for the selected
609
+ blocks.
610
+ */
611
+ declare const toggleList: Command.Pure<Plot.Tag>;
612
+ /**
613
+ Returns true when all selected textblocks are wrapped in a list of
614
+ the given type.
615
+ */
616
+ declare const listIsActive: (listTag: Plot.Tag) => (state: GardState) => boolean;
617
+ /**
618
+ Move the selection head one unit (text cluster, atomic node, or
619
+ node boundary) in the indicated direction. When `extend` is true,
620
+ keep the selection anchor in place. The default handler moves
621
+ visually through bidirectional text, so when going left, the
622
+ motion will go back in left-to-right text, and
623
+ forward in right-to-left text.
624
+ */
625
+ declare const moveByUnit: Command.Pure<{
626
+ dir: "left" | "right" | "forward" | "backward";
627
+ extend?: boolean;
628
+ }>;
629
+ /**
630
+ Move the selection head one word in the indicated direction. Keep
631
+ the anchor in place if `extend` is true. The default handler moves
632
+ visually.
633
+ */
634
+ declare const moveByWord: Command.Pure<{
635
+ dir: "left" | "right";
636
+ extend?: boolean;
637
+ }>;
638
+ /**
639
+ Move the selection head one line up or down. When `extend` is
640
+ true, keep the anchor in place.
641
+ */
642
+ declare const moveByLine: Command<{
643
+ dir: "up" | "down";
644
+ extend?: boolean;
645
+ }>;
646
+ /**
647
+ Move the selection head one page up or down. Extend the selection
648
+ when the `extend` flag is true.
649
+ */
650
+ declare const moveByPage: Command<{
651
+ dir: "up" | "down";
652
+ extend?: boolean;
653
+ }>;
654
+ /**
655
+ Move to the indicated side of the current line. Will stop at line
656
+ wrap points. `"left"` and `"right"` will be interpreted based on
657
+ the editor's text direction.
658
+ */
659
+ declare const moveToLineSide: Command<{
660
+ dir: "left" | "right" | "forward" | "backward";
661
+ extend?: boolean;
662
+ }>;
663
+ /**
664
+ Move to the start or end of the textblock that has the selection
665
+ head.
666
+ */
667
+ declare const moveToTextblockSide: Command<{
668
+ dir: "left" | "right" | "forward" | "backward";
669
+ extend?: boolean;
670
+ }>;
671
+ /**
672
+ Move to the start or end of the document.
673
+ */
674
+ declare const moveToDocSide: Command.Pure<{
675
+ side: "start" | "end";
676
+ extend?: boolean;
677
+ }>;
678
+ /**
679
+ Select the entire document.
680
+ */
681
+ declare const selectAll: Command.Pure;
682
+ /**
683
+ Undo an edit. Does not have a default handler, but a handler is
684
+ added by the history extension.
685
+ */
686
+ declare const undo: Command;
687
+ /**
688
+ Redo an edit. Does not have a default handler.
689
+ */
690
+ declare const redo: Command;
691
+
692
+ /**
693
+ If the cursor is in an empty textblock that can be lifted out of a
694
+ parent, return a transaction that does this.
695
+ */
696
+ declare function liftEmptyBlock(state: GardState): Transaction.Spec | false;
697
+ /**
698
+ If the selection is in a {@link Plot.Spec.preserveWhitespace
699
+ `preserveWhitespace`} textblock, replace the selected content with
700
+ a {@link Schema.lineBreak line break}.
701
+
702
+ If the selection additionally is a cursor on an otherwise empty
703
+ line after a blank line, split or trunctate (if at end) the parent
704
+ textblock and create a blank default text block in place of the
705
+ empty line.
706
+ */
707
+ declare function enterInCode(state: GardState): Transaction.Spec | false;
708
+ /**
709
+ Split the textblock at the cursor position, if any. If the
710
+ textblock is the first child of a list item, also split that item,
711
+ unless `splitListItem` is false.
712
+ */
713
+ declare function splitTextblock(state: GardState, splitListItem?: boolean): Transaction.Spec | false;
714
+ /**
715
+ Returns a transaction that deletes the selection, or false if the
716
+ selection is empty.
717
+ */
718
+ declare function deleteSelection(state: GardState): Transaction.Spec | false;
719
+ /**
720
+ If the cursor is inside an empty plot, return a transaction that
721
+ deletes the entire plot. `dir` determines which way the cursor
722
+ moves after the deletion.
723
+ */
724
+ declare function deleteEmptyPlot(state: GardState, dir?: -1 | 1): Transaction.Spec | false;
725
+ /**
726
+ If the cursor is at the start of a textblock that can be joined to
727
+ a textblock before it, return a transaction to performs this join.
728
+ */
729
+ declare function joinBackward(state: GardState): Transaction.Spec | false;
730
+ /**
731
+ If the cursor is at the start of a list item that has another item
732
+ before it, return a transaction that joins those two items.
733
+ */
734
+ declare function joinListItems(state: GardState): Transaction.Spec | false;
735
+ /**
736
+ If the cursor is at the end of a textblock that can be joined to
737
+ the textblock after it, return a transaction that performs this
738
+ join.
739
+ */
740
+ declare function joinForward(state: GardState): Transaction.Spec | false;
741
+ /**
742
+ Create a transaction that deletes the atomic node or text
743
+ cluster/word in front of the cursor, if possible.
744
+ */
745
+ declare function deleteBackward(state: GardState, word?: boolean): Transaction.Spec | false;
746
+ /**
747
+ Return a transaction that deletes the element (text cluster or
748
+ leaf node) after the cursor, if any.
749
+ */
750
+ declare function deleteForward(state: GardState, word?: boolean): Transaction.Spec | false;
751
+ /**
752
+ Get an array of all textblocks that contain part of the selection.
753
+ */
754
+ declare function selectedTextblocks(state: GardState): Pos.Plot[];
755
+ /**
756
+ Remove all content in `node` that is not allowed to appear in
757
+ `type`.
758
+ */
759
+ declare function clearNonFitting(schema: Schema, node: Pos.Plot, type: Plot.Type): ChangeSet.Spec;
760
+ /**
761
+ Find a way to wrap the blocks betwen `from` and `to` in a node
762
+ with the given tag. Returns precise start and end positions where
763
+ a wrap is possible, or null if none is possible.
764
+ */
765
+ declare function findWrappable(from: Pos, to: Pos, wrapper: Plot.Tag): {
766
+ from: Pos;
767
+ to: Pos;
768
+ } | null;
769
+ /**
770
+ Wrap the given range in the given wrapper tag. The caller is
771
+ responsible for verifying that this is actually a valid wrapping.
772
+ It is recommended to use {@link findWrappable} for finding wrap
773
+ positions in non-trivial situations.
774
+ */
775
+ declare function wrapBlockRange(range: {
776
+ from: Pos;
777
+ to: Pos;
778
+ }, wrapper: Plot.Tag): ChangeSet.Spec[];
779
+ /**
780
+ Find the set of block nodes around the given range that match the
781
+ predicate (if any) and can be unwrapped, meaning their content
782
+ gets moved out to a parent node.
783
+ */
784
+ declare function findUnwrappable(schema: Schema, from: Pos, to: Pos, query?: Node.Query): Pos.Plot[] | null;
785
+ /**
786
+ Unwrap the given block node, or the node's children between `from`
787
+ and `to`.
788
+ */
789
+ declare function doUnwrapBlock(block: Pos.Plot, from?: number, to?: number): ChangeSet.Spec;
790
+ /**
791
+ Join two adjacent (only separated by first a sequence of block end
792
+ tokens and then a sequence of block open tokens) block plots.
793
+ */
794
+ declare function joinBlocks(before: Pos.Plot, after: Pos.Plot): ChangeSet.Spec;
795
+ /**
796
+ Query whether the given range has any content to which the given
797
+ mark or mark type could be added.
798
+ */
799
+ declare function canAddMarkInRange(doc: Plot.Doc, from: number, to: number, mark: Mark | Mark.Type): boolean;
800
+ /**
801
+ Post-process the given transaction spec to check for any block
802
+ boundaries touched by the changes in it that can be {@link
803
+ Plot.Spec.autoJoin auto-joined}. If any are found, the spec is
804
+ updated to perform those joins.
805
+ */
806
+ declare function autoJoinBlocks(state: GardState, tr: Transaction.Spec): Transaction.Spec;
807
+
808
+ export { Command, Menu, autoJoinBlocks, canAddMarkInRange, clearNonFitting, deleteBackward, deleteEmptyPlot, deleteForward, deleteLine, deleteSelection, deleteToLineEnd, deleteUnit, deleteWord, doUnwrapBlock, enter, enterInCode, findUnwrappable, findWrappable, insertLineBreak, insertText, joinBackward, joinBlocks, joinForward, joinListItems, liftEmptyBlock, listIsActive, moveByLine, moveByPage, moveByUnit, moveByWord, moveToDocSide, moveToLineSide, moveToTextblockSide, redo, selectAll, selectedTextblocks, setAlignment, setDirection, setTextblockType, splitTextblock, toggleBlock, toggleEmphasis, toggleList, toggleMark, toggleStrong, toggleUnderline, transposeChars, undo, unwrapBlock, wrapBlock, wrapBlockRange };