@fusion.dev/helix-headless 0.238.0 → 0.239.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.
@@ -18,6 +18,14 @@ export declare const EDITOR_BLOCKS: readonly EditorTool[];
18
18
  declare const GROUPS: readonly [readonly ["history", readonly ["undo", "redo"]], readonly ["block", readonly EditorTool[]], readonly ["marks", readonly ["bold", "italic", "strike", "code"]], readonly ["link", readonly ["link"]], readonly ["lists", readonly ["bullet-list", "ordered-list"]], readonly ["quote", readonly ["quote"]]];
19
19
  /** A group of tools that `tools` names: the groups above, and `find`, the button that opens the find bar, which is drawn only where `tools` names it. */
20
20
  export type EditorToolGroup = (typeof GROUPS)[number][0] | 'find';
21
+ /**
22
+ * What stands on the toolbar, in the order it is drawn: each tool, the block
23
+ * menu as `block`, and the Find button as `find`. A narrow toolbar folds them
24
+ * from the end into the overflow menu, one at a time.
25
+ */
26
+ declare const BAR: readonly ['undo', 'redo', 'block', 'bold', 'italic', 'strike', 'code', 'link', 'bullet-list', 'ordered-list', 'quote', 'find'];
27
+ /** One thing on the toolbar that can fold into the overflow menu. */
28
+ type BarTool = (typeof BAR)[number];
21
29
  /** What the frame asks of whatever draws the document, as the frame's settings stand. */
22
30
  export interface EditorSettings {
23
31
  /** The document's name, which the renderer gives the element that takes the text. */
@@ -107,6 +115,15 @@ export interface EditorSink {
107
115
  * selection is disabled. A tool returns focus to the document once it has run.
108
116
  * With `readonly`, the document cannot be edited and the toolbar is not drawn.
109
117
  *
118
+ * **A toolbar too narrow for its tools folds them into a menu.** The tools
119
+ * fold from the end, one at a time, into a menu behind a button after the
120
+ * last tool on the bar, named by `more-label`, until the row fits, so Undo
121
+ * and Redo stay on the bar longest. Your `actions` stay at the end of the
122
+ * row. In the menu the tools keep their groups, a mark, a list, or the quote
123
+ * is checked while its format holds, the block types are a submenu, and Link
124
+ * and Find open their bars as their buttons do. A server draws every tool on
125
+ * the row, and the browser folds what does not fit once it has measured it.
126
+ *
110
127
  * Command+F opens a find bar under the toolbar, a Find that searches the
111
128
  * document through the renderer, marks every match, and selects one. It
112
129
  * replaces unless the document is `readonly`, which it searches too.
@@ -145,6 +162,7 @@ export interface EditorSink {
145
162
  * @slot footer - Content under the document, such as a word count or whether it is saved.
146
163
  * @slot italic-icon - Replaces the glyph inside the Italic button.
147
164
  * @slot link-icon - Replaces the glyph inside the Link button.
165
+ * @slot more-icon - Replaces the glyph on the button that opens the overflow menu.
148
166
  * @slot ordered-list-icon - Replaces the glyph inside the Numbered list button.
149
167
  * @slot quote-icon - Replaces the glyph inside the Quote button.
150
168
  * @slot redo-icon - Replaces the glyph inside the Redo button.
@@ -298,12 +316,40 @@ export interface EditorSink {
298
316
  * @csspart link-remove-text - The box the Remove button's icon sits in.
299
317
  * @csspart link-spinner - The ring the Link button turns while it is pending.
300
318
  * @csspart link-text - The box the Link button's icon sits in.
319
+ * @csspart more - The button that opens the overflow menu, drawn after the last tool on the bar while any tool has folded.
320
+ * @csspart more-button - The overflow button's inner button.
321
+ * @csspart more-live - The overflow button's live region, which speaks while the button is pending.
322
+ * @csspart more-spinner - The ring the overflow button turns while it is pending.
323
+ * @csspart more-text - The box the overflow button's icon sits in.
301
324
  * @csspart ordered-list - The Numbered list button. Pressed while the selection is in a numbered list.
302
325
  * @csspart ordered-list-button - The Numbered list button's inner button.
303
326
  * @csspart ordered-list-live - The Numbered list button's live region, which speaks while the button is pending.
304
327
  * @csspart ordered-list-pressed - The Numbered list button while the selection is in a numbered list, beside `ordered-list`.
305
328
  * @csspart ordered-list-spinner - The ring the Numbered list button turns while it is pending.
306
329
  * @csspart ordered-list-text - The box the Numbered list button's icon sits in.
330
+ * @csspart overflow - The menu of the tools that do not fit on the toolbar.
331
+ * @csspart overflow-back - The control that returns from the block types' submenu.
332
+ * @csspart overflow-back-mark - The glyph on the back control of a submenu.
333
+ * @csspart overflow-divider - The rule between two groups of tools in the overflow menu.
334
+ * @csspart overflow-divider-content - The content set into that rule, which the editor sets none into.
335
+ * @csspart overflow-divider-line - The line of that rule.
336
+ * @csspart overflow-empty - The text shown when the menu has no items.
337
+ * @csspart overflow-header - The bar above a submenu, holding the way back and its name.
338
+ * @csspart overflow-live - The overflow menu's live region, which repeats the empty and loading text for screen readers.
339
+ * @csspart overflow-loading - The text shown while the items are loading.
340
+ * @csspart overflow-option - One tool in the overflow menu. A mark, a list, or the quote is checked while its format holds.
341
+ * @csspart overflow-option-end - A tool's trailing column.
342
+ * @csspart overflow-option-item - A tool's row.
343
+ * @csspart overflow-option-mark - The check beside a tool whose format holds, or the caret of the block types' row.
344
+ * @csspart overflow-option-shortcut - A tool's key.
345
+ * @csspart overflow-option-shortcut-kbd - The key inside it.
346
+ * @csspart overflow-option-shortcut-key - One key of a tool's chord.
347
+ * @csspart overflow-option-shortcut-separator - The `+` between two keys of a tool's chord.
348
+ * @csspart overflow-option-start - A tool's leading column, which holds its glyph.
349
+ * @csspart overflow-option-surface - The block types' submenu panel, under `submenus="flyout"`.
350
+ * @csspart overflow-search-field - The overflow menu's filter field, drawn with `filterable`.
351
+ * @csspart overflow-surface - The floating panel the overflow menu is drawn on.
352
+ * @csspart overflow-title - The name of the submenu that is showing.
307
353
  * @csspart quote - The Quote button. Pressed while the selection is in a quote.
308
354
  * @csspart quote-button - The Quote button's inner button.
309
355
  * @csspart quote-live - The Quote button's live region, which speaks while the button is pending.
@@ -322,7 +368,7 @@ export interface EditorSink {
322
368
  * @csspart strike-pressed - The Strikethrough button while the selection is struck through, beside `strike`.
323
369
  * @csspart strike-spinner - The ring the Strikethrough button turns while it is pending.
324
370
  * @csspart strike-text - The box the Strikethrough button's icon sits in.
325
- * @csspart tools - A group of several tools, which a narrow toolbar wraps as one: Undo and Redo, the marks, or the lists and the quote.
371
+ * @csspart tools - A group of several tools: Undo and Redo, the marks, or the lists and the quote.
326
372
  * @csspart undo - The Undo button. Disabled while there is nothing to undo.
327
373
  * @csspart undo-button - The Undo button's inner button.
328
374
  * @csspart undo-live - The Undo button's live region, which speaks while the button is pending.
@@ -382,6 +428,8 @@ export declare class HelixHeadlessEditor extends HelixElement {
382
428
  linkLabel: string;
383
429
  /** The Remove button's label in the address bar. */
384
430
  linkRemoveLabel: string;
431
+ /** The name of the button that opens the overflow menu, and of the menu. */
432
+ moreLabel: string;
385
433
  /** The Numbered list button's label. */
386
434
  orderedListLabel: string;
387
435
  /** The Paragraph row's label in the block menu. */
@@ -424,8 +472,18 @@ export declare class HelixHeadlessEditor extends HelixElement {
424
472
  private hasActions;
425
473
  /** Escape was the last key in the document, so Tab leaves it. */
426
474
  private escaped;
427
- /** A choice in the block menu is waiting for the menu to close before focus goes back to the document. */
428
- private chosen;
475
+ /**
476
+ * What runs once a menu in the toolbar has closed: focus back to the
477
+ * document after a choice, or a bar opened from the overflow menu. It waits
478
+ * for the close, because the menu puts focus back on its trigger as it
479
+ * closes.
480
+ */
481
+ private afterMenu;
482
+ /**
483
+ * Folds the tools that do not fit on the toolbar into the overflow menu,
484
+ * from the end: step `n` folds the last `n` of `onBar`.
485
+ */
486
+ private readonly overflow;
429
487
  /**
430
488
  * Hands the frame what draws the document. The frame sends it the settings
431
489
  * now and as they change, asks it to run the tools the reader presses, and
@@ -528,8 +586,22 @@ export declare class HelixHeadlessEditor extends HelixElement {
528
586
  private readonly keepTick;
529
587
  /** A block type was chosen in the menu. */
530
588
  private choose;
531
- /** The block menu closed: focus goes back to the document after a choice. */
589
+ /** A tool was chosen in the overflow menu: it runs, and focus goes back to the document. */
590
+ private chooseFolded;
591
+ /** A menu in the toolbar closed: what was waiting for it runs. */
532
592
  private readonly handleMenuToggle;
593
+ /** What stands on the toolbar now, in the order it is drawn: nothing while `readonly`. */
594
+ private get onBar();
595
+ /** The tools step `step` folds: the last `step` on the bar. */
596
+ private foldedAt;
597
+ /** Whether every one of `tools` has folded, which hides what holds them on the bar. */
598
+ private allFolded;
599
+ /**
600
+ * Writes a step onto the toolbar as its render draws it: each tool, group,
601
+ * and line whose tools have all folded is hidden, and the overflow menu
602
+ * shows while anything has folded.
603
+ */
604
+ private fold;
533
605
  connectedCallback(): void;
534
606
  disconnectedCallback(): void;
535
607
  protected firstUpdated(changed: PropertyValues): void;
@@ -547,6 +619,16 @@ export declare class HelixHeadlessEditor extends HelixElement {
547
619
  * turns on a right-to-left page with the line.
548
620
  */
549
621
  private renderPointing;
622
+ /** A tool's glyph, on its button or on its row in the overflow menu. */
623
+ private glyphOf;
624
+ /**
625
+ * A tool's glyph on its button: inside the slot that replaces it while the
626
+ * tool is on the bar, and alone once it has folded, when the slot moves to
627
+ * the tool's row in the overflow menu. A slot takes its content in one place.
628
+ */
629
+ protected renderBarIcon(tool: BarTool): TemplateResult;
630
+ /** Those of `tools` that stand on the bar. */
631
+ private drawnOf;
550
632
  /** Undo and Redo. */
551
633
  protected renderHistory(): TemplateResult | typeof nothing;
552
634
  /** Bold, Italic, Strikethrough, and Code, each pressed while its mark holds. */
@@ -560,7 +642,7 @@ export declare class HelixHeadlessEditor extends HelixElement {
560
642
  protected renderLists(): TemplateResult | typeof nothing;
561
643
  /**
562
644
  * The lists and the quote, one group: each wraps the blocks it holds, so
563
- * they stand together on the toolbar, and a narrow one wraps them as one.
645
+ * they stand together on the toolbar and in the overflow menu.
564
646
  */
565
647
  protected renderBlocks(): TemplateResult | typeof nothing;
566
648
  /** Quote, pressed while the selection is in one. */
@@ -574,8 +656,13 @@ export declare class HelixHeadlessEditor extends HelixElement {
574
656
  * the selection moves between a paragraph and a heading.
575
657
  */
576
658
  protected renderBlockMenu(): TemplateResult | typeof nothing;
577
- /** A line between two groups of tools. */
578
- protected renderDivider(): TemplateResult;
659
+ /**
660
+ * A row for each block type, the selection's checked: in the block menu,
661
+ * or in the submenu of the overflow menu's block row with `slot`.
662
+ */
663
+ protected renderBlockOptions(slot?: string): TemplateResult[];
664
+ /** A line between two groups of tools, before `tools`, hidden once they have all folded. */
665
+ protected renderDivider(tools?: readonly BarTool[]): TemplateResult;
579
666
  /** The Find button, which opens and closes the find bar: expanded while it is open. */
580
667
  protected renderFindTool(): TemplateResult | typeof nothing;
581
668
  /**
@@ -595,6 +682,18 @@ export declare class HelixHeadlessEditor extends HelixElement {
595
682
  * nothing can be slotted into.
596
683
  */
597
684
  protected renderControls(): TemplateResult;
685
+ /**
686
+ * The overflow menu, after the last tool on the bar: the tools that do not
687
+ * fit, in their groups with a line between two. Kept in the tree while
688
+ * nothing has folded, hidden, so a measure can show it at once.
689
+ */
690
+ protected renderOverflow(): TemplateResult | typeof nothing;
691
+ /**
692
+ * A tool's row in the overflow menu, with the glyph its button has. A mark,
693
+ * a list, or the quote is checked while its format holds; the block types
694
+ * are a submenu; Link and Find open their bars once the menu has closed.
695
+ */
696
+ protected renderFolded(tool: BarTool): TemplateResult;
598
697
  /**
599
698
  * The address bar, kept in the tree while closed so its field keeps what
600
699
  * was written. The field stands before the toolbar and outside it, because a