@openleaf-editor/ui 0.1.0-beta.1 → 0.1.0-beta.3

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.
Files changed (82) hide show
  1. package/README.md +85 -0
  2. package/dist/block-type.d.ts +5 -0
  3. package/dist/block-type.d.ts.map +1 -0
  4. package/dist/block-type.js +133 -0
  5. package/dist/block-type.js.map +1 -0
  6. package/dist/content-css.d.ts +31 -0
  7. package/dist/content-css.d.ts.map +1 -0
  8. package/dist/content-css.js +272 -0
  9. package/dist/content-css.js.map +1 -0
  10. package/dist/css.d.ts +23 -0
  11. package/dist/css.d.ts.map +1 -0
  12. package/dist/css.js +813 -0
  13. package/dist/css.js.map +1 -0
  14. package/dist/dialog.d.ts +158 -18
  15. package/dist/dialog.d.ts.map +1 -1
  16. package/dist/dialog.js +605 -130
  17. package/dist/dialog.js.map +1 -1
  18. package/dist/floating.d.ts +29 -0
  19. package/dist/floating.d.ts.map +1 -0
  20. package/dist/floating.js +130 -0
  21. package/dist/floating.js.map +1 -0
  22. package/dist/help.d.ts +9 -0
  23. package/dist/help.d.ts.map +1 -0
  24. package/dist/help.js +97 -0
  25. package/dist/help.js.map +1 -0
  26. package/dist/i18n.d.ts +39 -0
  27. package/dist/i18n.d.ts.map +1 -0
  28. package/dist/i18n.js +114 -0
  29. package/dist/i18n.js.map +1 -0
  30. package/dist/icons.d.ts +7 -1
  31. package/dist/icons.d.ts.map +1 -1
  32. package/dist/icons.js +10 -2
  33. package/dist/icons.js.map +1 -1
  34. package/dist/index.d.ts +15 -7
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +14 -6
  37. package/dist/index.js.map +1 -1
  38. package/dist/items.d.ts +2 -1
  39. package/dist/items.d.ts.map +1 -1
  40. package/dist/items.js +263 -17
  41. package/dist/items.js.map +1 -1
  42. package/dist/live.d.ts +42 -0
  43. package/dist/live.d.ts.map +1 -0
  44. package/dist/live.js +83 -0
  45. package/dist/live.js.map +1 -0
  46. package/dist/menu.d.ts +85 -0
  47. package/dist/menu.d.ts.map +1 -0
  48. package/dist/menu.js +500 -0
  49. package/dist/menu.js.map +1 -0
  50. package/dist/openleaf.css +325 -7
  51. package/dist/overflow.d.ts +44 -0
  52. package/dist/overflow.d.ts.map +1 -0
  53. package/dist/overflow.js +323 -0
  54. package/dist/overflow.js.map +1 -0
  55. package/dist/pickers.d.ts +43 -0
  56. package/dist/pickers.d.ts.map +1 -0
  57. package/dist/pickers.js +52 -0
  58. package/dist/pickers.js.map +1 -0
  59. package/dist/registry.d.ts +72 -18
  60. package/dist/registry.d.ts.map +1 -1
  61. package/dist/registry.js +7 -6
  62. package/dist/registry.js.map +1 -1
  63. package/dist/skins.d.ts.map +1 -1
  64. package/dist/skins.js +48 -14
  65. package/dist/skins.js.map +1 -1
  66. package/dist/styles.d.ts +61 -1
  67. package/dist/styles.d.ts.map +1 -1
  68. package/dist/styles.js +77 -421
  69. package/dist/styles.js.map +1 -1
  70. package/dist/testing.d.ts +3 -0
  71. package/dist/testing.d.ts.map +1 -0
  72. package/dist/testing.js +3 -0
  73. package/dist/testing.js.map +1 -0
  74. package/dist/toolbar.d.ts +91 -12
  75. package/dist/toolbar.d.ts.map +1 -1
  76. package/dist/toolbar.js +459 -127
  77. package/dist/toolbar.js.map +1 -1
  78. package/dist/upload.d.ts +11 -0
  79. package/dist/upload.d.ts.map +1 -1
  80. package/dist/upload.js +15 -1
  81. package/dist/upload.js.map +1 -1
  82. package/package.json +17 -3
package/dist/toolbar.d.ts CHANGED
@@ -13,13 +13,16 @@
13
13
  *
14
14
  * Two details that are easy to get wrong and both matter:
15
15
  *
16
- * 1. **Arrow-key roving is applied only to `<button>` elements.** The block-type
17
- * control is a native `<select>`, and when focus is on it, Left/Right have two
18
- * competing owners -- the roving handler wants to move to the next item, the
19
- * select natively wants to change its value. Intercepting those keys breaks
20
- * the select; not intercepting them breaks the toolbar contract. The
21
- * resolution is that the select owns all of its own key events and is a
22
- * genuine second tab stop rather than part of the roving scheme.
16
+ * 1. **Arrow-key roving covers the `<select>` controls too.** The default bar has
17
+ * four of them -- paragraph style, font family, font size, line height -- and
18
+ * when focus is on one, Left/Right have two competing owners: the roving
19
+ * handler wants to move to the next item, the select natively wants to change
20
+ * its value. Leaving them out was the earlier resolution, and it cost more
21
+ * than it saved: ArrowRight from Redo jumped past four controls to Bold, and
22
+ * each select became its own tab stop, making the default bar five tab stops
23
+ * instead of one. The APG resolution is the one used here -- the toolbar takes
24
+ * Left/Right, and Up/Down, Home/End and typeahead are left to the select, so
25
+ * it is still fully operable and Alt+Down still opens its list.
23
26
  *
24
27
  * 2. **Escape returns focus and the selection to the content.** Preventing mouse
25
28
  * clicks from stealing focus solves the mouse case and leaves the keyboard
@@ -28,6 +31,7 @@
28
31
  * is blind-Tabbing through the rest of the host's form. `Alt+F10` enters,
29
32
  * Escape leaves, matching TinyMCE and CKEditor 5 so muscle memory transfers.
30
33
  */
34
+ import { type FormatSpec } from '@openleaf-editor/core';
31
35
  import type { EditorState, Transaction } from 'prosemirror-state';
32
36
  import type { EditorView } from 'prosemirror-view';
33
37
  export interface ToolbarOptions {
@@ -35,23 +39,98 @@ export interface ToolbarOptions {
35
39
  label?: string;
36
40
  /** Space-separated item ids, `|` for a separator. */
37
41
  layout?: string;
42
+ /**
43
+ * Collapse groups that do not fit into a More menu. Off by default: wrapping
44
+ * keeps every control visible, which is the safer accessibility default.
45
+ */
46
+ overflow?: boolean;
47
+ /** Extra block formats, typically classes from the host's content CSS. */
48
+ formats?: readonly FormatSpec[];
49
+ /**
50
+ * Language for this toolbar's labels, independent of every other editor's.
51
+ * Absent means the document-wide locale.
52
+ */
53
+ locale?: string | null;
54
+ }
55
+ /**
56
+ * What a host or a plugin actually needs from a toolbar.
57
+ *
58
+ * Published instead of the `Toolbar` class itself. The documented need is
59
+ * `setItemState` -- pushing state no predicate can derive, such as an upload in
60
+ * flight -- and the keyboard entry point; exposing the class froze its whole
61
+ * surface, private fields and rendering internals included, into the public API
62
+ * before 1.0.
63
+ */
64
+ export interface ToolbarHandle {
65
+ /** Force a control's state, overriding its `isActive`/`isEnabled` predicate. */
66
+ setItemState(id: string, state: {
67
+ active?: boolean;
68
+ enabled?: boolean;
69
+ }): void;
70
+ /** Move focus into the bar, as Alt+F10 does. */
71
+ focusToolbar(): void;
38
72
  }
39
73
  export declare class Toolbar {
40
74
  #private;
41
75
  readonly el: HTMLDivElement;
42
76
  constructor(host: HTMLElement, doc: Document, options?: ToolbarOptions);
77
+ /**
78
+ * Change this toolbar's language and rebuild its labels.
79
+ *
80
+ * Per toolbar rather than per document, so one editor switching language does
81
+ * not relabel every other editor on the page.
82
+ */
83
+ setLocale(next: string | null): void;
84
+ /**
85
+ * Enter or leave source view.
86
+ *
87
+ * Every control except the one that leaves again goes unavailable. In source
88
+ * mode a formatting command ran against the hidden document and the textarea
89
+ * was then reparsed over the top of it, so pressing Bold silently discarded
90
+ * the edit -- a button that does nothing is better than a button that
91
+ * destroys work, and a button that says it is unavailable is better still.
92
+ */
93
+ setSourceMode(active: boolean): void;
43
94
  /** Attach to a view and build the controls. */
44
95
  mount(view: EditorView): void;
96
+ /**
97
+ * Detach the toolbar AND take its DOM with it.
98
+ *
99
+ * Removing the nodes is part of the contract, not tidiness. The host appends
100
+ * `el` into the editor element and reads that element's
101
+ * `innerHTML` back as document content when it rebuilds -- so a toolbar left
102
+ * behind by `destroy()` becomes the author's document on the next build, and
103
+ * then gets posted to the server.
104
+ *
105
+ * Idempotent: `.remove()` on a detached node is a no-op.
106
+ */
45
107
  destroy(): void;
46
- /** The live region element, which the host mounts once. */
108
+ /**
109
+ * The editor's live region.
110
+ *
111
+ * One per host, shared by every bar on it, and already mounted -- so a host
112
+ * that appends this is moving a node it already owns rather than adopting a
113
+ * detached one. Kept on the class because integrations reach for it.
114
+ */
47
115
  get liveRegion(): HTMLDivElement;
48
116
  /**
49
117
  * Reflect the editor state onto the controls.
50
118
  *
51
- * Deliberately synchronous, not batched into an animation frame. Twenty cheap
52
- * predicates plus a diffed attribute write is sub-millisecond work, and
53
- * batching would trade a perceptible frame of lag between pressing Bold and
54
- * the button lighting up for a performance problem that does not exist.
119
+ * Deliberately synchronous, not batched into an animation frame: batching
120
+ * would put a perceptible frame of lag between pressing Bold and the button
121
+ * lighting up.
122
+ *
123
+ * This used to claim the predicates were "sub-millisecond work" and that the
124
+ * performance problem "does not exist". It did. Every control without an
125
+ * `isEnabled` is probed by dry-running its command, each of which walks the
126
+ * selection, and a page routinely carries four bars over one editor -- so a
127
+ * Select-All on a hundred-page document measured 1.4 ms per bar and about
128
+ * 3 ms per pointermove during a selection drag, inside `dispatchTransaction`.
129
+ * What makes synchronous affordable is the three guards below it: skipping
130
+ * transactions that cannot have changed an answer, caching each answer per
131
+ * state so the four bars share one computation, and giving the alignment items
132
+ * an explicit `isEnabled` so they stop dry-running a command that walks the
133
+ * selection twice.
55
134
  *
56
135
  * `tr` is passed so announcements can be gated on a real formatting change.
57
136
  */
@@ -1 +1 @@
1
- {"version":3,"file":"toolbar.d.ts","sourceRoot":"","sources":["../src/toolbar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAWlD,MAAM,WAAW,cAAc;IAC7B,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAuDD,qBAAa,OAAO;;IAClB,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAA;gBAgBf,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,GAAE,cAAmB;IA8B1E,+CAA+C;IAC/C,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAM7B,OAAO,IAAI,IAAI;IA6Bf,2DA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