@openleaf-editor/ui 0.1.0-beta.2 → 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 (78) 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 +18 -0
  7. package/dist/content-css.d.ts.map +1 -1
  8. package/dist/content-css.js +231 -16
  9. package/dist/content-css.js.map +1 -1
  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 +93 -0
  15. package/dist/dialog.d.ts.map +1 -1
  16. package/dist/dialog.js +414 -86
  17. package/dist/dialog.js.map +1 -1
  18. package/dist/floating.d.ts +4 -0
  19. package/dist/floating.d.ts.map +1 -1
  20. package/dist/floating.js +50 -2
  21. package/dist/floating.js.map +1 -1
  22. package/dist/help.d.ts +1 -1
  23. package/dist/help.d.ts.map +1 -1
  24. package/dist/help.js +29 -5
  25. package/dist/help.js.map +1 -1
  26. package/dist/i18n.d.ts +8 -0
  27. package/dist/i18n.d.ts.map +1 -1
  28. package/dist/i18n.js +32 -7
  29. package/dist/i18n.js.map +1 -1
  30. package/dist/icons.d.ts +7 -1
  31. package/dist/icons.d.ts.map +1 -1
  32. package/dist/icons.js +6 -2
  33. package/dist/icons.js.map +1 -1
  34. package/dist/index.d.ts +10 -8
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +8 -6
  37. package/dist/index.js.map +1 -1
  38. package/dist/items.d.ts +0 -1
  39. package/dist/items.d.ts.map +1 -1
  40. package/dist/items.js +226 -20
  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 +31 -2
  47. package/dist/menu.d.ts.map +1 -1
  48. package/dist/menu.js +163 -23
  49. package/dist/menu.js.map +1 -1
  50. package/dist/openleaf.css +114 -12
  51. package/dist/overflow.d.ts +31 -4
  52. package/dist/overflow.d.ts.map +1 -1
  53. package/dist/overflow.js +267 -82
  54. package/dist/overflow.js.map +1 -1
  55. package/dist/registry.d.ts +72 -18
  56. package/dist/registry.d.ts.map +1 -1
  57. package/dist/registry.js +7 -6
  58. package/dist/registry.js.map +1 -1
  59. package/dist/skins.d.ts.map +1 -1
  60. package/dist/skins.js +48 -14
  61. package/dist/skins.js.map +1 -1
  62. package/dist/styles.d.ts +61 -1
  63. package/dist/styles.d.ts.map +1 -1
  64. package/dist/styles.js +77 -637
  65. package/dist/styles.js.map +1 -1
  66. package/dist/testing.d.ts +3 -0
  67. package/dist/testing.d.ts.map +1 -0
  68. package/dist/testing.js +3 -0
  69. package/dist/testing.js.map +1 -0
  70. package/dist/toolbar.d.ts +71 -12
  71. package/dist/toolbar.d.ts.map +1 -1
  72. package/dist/toolbar.js +410 -166
  73. package/dist/toolbar.js.map +1 -1
  74. package/dist/upload.d.ts +11 -0
  75. package/dist/upload.d.ts.map +1 -1
  76. package/dist/upload.js +15 -1
  77. package/dist/upload.js.map +1 -1
  78. package/package.json +17 -3
package/dist/styles.js CHANGED
@@ -26,6 +26,9 @@
26
26
  * 1. A constructable `CSSStyleSheet` added to `document.adoptedStyleSheets`.
27
27
  * CSP gates resources *parsed as style*; a CSSOM object attached this way
28
28
  * never passes through that gate, by design rather than by loophole.
29
+ * Constructed through the TARGET document's window, never this module's:
30
+ * a constructed sheet belongs to the document it was built for, and
31
+ * adopting it elsewhere throws NotAllowedError.
29
32
  * 2. The integrator links `@openleaf-editor/ui/openleaf.css` themselves and calls
30
33
  * `markStylesExternal()`.
31
34
  *
@@ -34,642 +37,66 @@
34
37
  * would need it, and it fails *silently* -- an unstyled toolbar with no signal
35
38
  * an integrator can act on. A console warning naming the stylesheet is more
36
39
  * useful than a mechanism that quietly does nothing.
37
- */
38
- /**
39
- * The dark palette, as fallbacks for the same public tokens the light one uses.
40
40
  *
41
- * Written once and applied from three selectors below rather than pasted three
42
- * times, because the failure mode of a pasted palette is one selector quietly
43
- * missing a line -- and the line it is missing is a colour nobody looks at until
44
- * it is the wrong one.
41
+ * ## Why the accessibility reasoning lives out here
42
+ *
43
+ * The bundles are minified, which strips these comments but NOT the contents of
44
+ * the template literal below -- a CSS comment is string data and ships to every
45
+ * user. So the long-form arguments sit here and the rules carry a short marker
46
+ * pointing back. Ratios below are computed with the WCAG 2.x sRGB formula
47
+ * against all four built-in palettes: default light, midnight, paper, contrast.
48
+ *
49
+ * ### Two border tokens
50
+ *
51
+ * `--ol-border` is 1.43:1 against the default surface (1.92 midnight, 1.47
52
+ * paper). That is right for a table rule or a group divider and wrong for the
53
+ * only thing delimiting a `<select>`, where WCAG 1.4.11 wants 3:1 for the parts
54
+ * of a control that identify it. Rather than darken every hairline in the
55
+ * editor, the two jobs are split: `--ol-border-strong` takes the control
56
+ * boundaries -- toolbar, menubar, content frame, source view, select, menu --
57
+ * and the decorative one stays quiet. The fallback clears 3:1 on a white
58
+ * surface (4.55:1) and a dark one (4.16:1) alike, so a third-party skin that
59
+ * sets only `--openleaf-color-border` still gets a legible control boundary.
60
+ *
61
+ * ### Menu focus
62
+ *
63
+ * `.ol-menu-item` had `outline: none` and a background swap standing in for the
64
+ * ring. That swap is 1.13:1 on the default palette, 1.24 midnight, 1.13 paper,
65
+ * and 1.23 in the skin named "High contrast"; 1.4.11 requires 3:1. A menu item
66
+ * is reachable only by ArrowDown, so that swap was the author's sole position
67
+ * marker. The ring is back and the swap stays as hover affordance. It is inset
68
+ * two pixels rather than outset so it is drawn inside the item rather than over
69
+ * the menu's padding and its neighbour, and it lands at 4.59:1 against the
70
+ * item's own hovered background (7.82 midnight, 4.88 paper, 9.73 contrast).
71
+ *
72
+ * ### Disabled is not invisible
73
+ *
74
+ * `opacity: 0.4` put a 16px glyph at 2.41:1 (2.34 paper, 2.85 contrast), which
75
+ * is not a dimmed icon but an absent one -- and `undo`, `redo` and `link` are
76
+ * disabled at rest. 0.55 stays plainly quieter than an enabled control while
77
+ * clearing 3:1 as non-text content. A disabled control is exempt from 1.4.3
78
+ * either way; being exempt from a rule is not a reason to be unreadable.
79
+ *
80
+ * ### Cell selection
81
+ *
82
+ * The `.selectedCell` tint alone measured 1.06-1.18:1 depending on the palette,
83
+ * and a selection you cannot see is one you will destroy by typing. The ring
84
+ * carries the information now and the tint is the nicety. The ring goes on the
85
+ * cell rather than on the `::after` overlay because the overlay's own `opacity`
86
+ * would fade it to the same invisibility -- a 40% accent lands near 2:1. Per
87
+ * CSS 2.1 Appendix E an element's outline paints in step 10, after all its
88
+ * descendants, so the tint does not cover it.
89
+ *
90
+ * ### Forced colours
91
+ *
92
+ * The block at the end of the sheet previously stopped at `.ol-btn`. Everything
93
+ * added to it depends on a palette this mode discards outright, so each of them
94
+ * had no indicator at all: which menu is open, which menu item has focus, which
95
+ * cells are selected, and every one of the visual aids -- whose entire output
96
+ * is a colour.
45
97
  */
46
- const DARK_TOKENS = `
47
- --ol-text: var(--openleaf-color-text, #e6edf3);
48
- --ol-text-muted: var(--openleaf-color-text-muted, #9198a1);
49
- --ol-surface: var(--openleaf-color-surface, #0d1117);
50
- --ol-surface-hover: var(--openleaf-color-surface-hover, #21262d);
51
- --ol-surface-active: var(--openleaf-color-surface-active, #1f3a5f);
52
- --ol-border: var(--openleaf-color-border, #3d444d);
53
- --ol-accent: var(--openleaf-color-accent, #79c0ff);
54
- --ol-focus: var(--openleaf-color-focus, #79c0ff);
55
- `;
56
- export const CSS = `
57
- .ol-editor {
58
- /* Two families, named before either is public API. A singular
59
- \`--openleaf-font\` implies "the" font, and source view already has a
60
- monospace surface -- bolting a mono token on beside a singular name later
61
- is the awkward outcome worth avoiding now. \`--openleaf-font\` is still
62
- honoured as a fallback. */
63
- --ol-font: var(--openleaf-font-ui, var(--openleaf-font, system-ui, -apple-system, "Segoe UI", sans-serif));
64
- --ol-font-mono: var(--openleaf-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
65
- --ol-font-size: var(--openleaf-font-size, 14px);
66
- --ol-radius: var(--openleaf-radius, 4px);
67
- --ol-text: var(--openleaf-color-text, #1f2328);
68
- --ol-text-muted: var(--openleaf-color-text-muted, #59636e);
69
- --ol-surface: var(--openleaf-color-surface, #ffffff);
70
- --ol-surface-hover: var(--openleaf-color-surface-hover, #f0f1f3);
71
- --ol-surface-active: var(--openleaf-color-surface-active, #dbe9ff);
72
- --ol-border: var(--openleaf-color-border, #d1d9e0);
73
- --ol-accent: var(--openleaf-color-accent, #0550ae);
74
- --ol-focus: var(--openleaf-color-focus, #0969da);
75
- --ol-button-size: var(--openleaf-button-size, 32px);
76
- --ol-icon-size: var(--openleaf-icon-size, 16px);
77
- --ol-gap: var(--openleaf-gap, 2px);
78
- /* A 2009 WordPress admin bar sits at z-index 99999 and Drupal's toolbar plays
79
- similar games. Without a sanctioned escape hatch integrators fix a toolbar
80
- rendered behind a sticky host header with !important -- the exact thing the
81
- token API exists to prevent. */
82
- --ol-z: var(--openleaf-z-index, 1);
83
- /* Thickness and offset, not just colour: "you can change the colour but not
84
- the thickness" is a poor answer to a Section 508 team citing WCAG 2.2
85
- Focus Appearance. */
86
- --ol-focus-width: var(--openleaf-focus-width, 2px);
87
- --ol-focus-offset: var(--openleaf-focus-offset, 1px);
88
-
89
- display: block;
90
- position: relative;
91
- color: var(--ol-text);
92
- }
93
-
94
- /* Three ways into the dark palette, and one way out of it.
95
- \`data-ol-scheme\` is set from the applied skin's declared scheme, and a skin
96
- that declares one outranks both the attribute and the system -- it has to,
97
- because its tokens have already replaced the palette outright. Without the
98
- \`:not()\` guards a light skin on a dark machine would take these fallbacks for
99
- every token it did not itself set, which is a light surface carrying dark-mode
100
- muted text. */
101
- @media (prefers-color-scheme: dark) {
102
- .ol-editor:not([data-ol-theme="light"]):not([data-ol-scheme]) {${DARK_TOKENS}}
103
- }
104
-
105
- .ol-editor[data-ol-theme="dark"]:not([data-ol-scheme]) {${DARK_TOKENS}}
106
-
107
- .ol-editor[data-ol-scheme="dark"] {${DARK_TOKENS}}
108
-
109
- /* Native widget chrome -- the popup a \`select\` opens, scrollbars, the caret,
110
- form control backgrounds -- is painted by the browser from \`color-scheme\`,
111
- not from any property we can hand an integrator. Left alone it follows the
112
- page, which is right while the editor's own palette also follows the page and
113
- wrong the moment either attribute pins the editor to one world. So it is set
114
- exactly when the editor stops following along, and inherited from the host
115
- otherwise. */
116
- .ol-editor[data-ol-theme="light"] { color-scheme: light; }
117
- .ol-editor[data-ol-theme="dark"] { color-scheme: dark; }
118
- .ol-editor[data-ol-scheme="light"] { color-scheme: light; }
119
- .ol-editor[data-ol-scheme="dark"] { color-scheme: dark; }
120
-
121
- /* Wrapping, not scrolling and not an overflow menu. Both of those hide
122
- controls -- one off-screen, one behind a click -- and a formatting control
123
- the author cannot see is a control they do not have. */
124
- .ol-editor .ol-toolbar {
125
- display: flex;
126
- flex-wrap: wrap;
127
- align-items: center;
128
- gap: var(--ol-gap);
129
- box-sizing: border-box;
130
- margin: 0;
131
- padding: 4px;
132
- border: 1px solid var(--ol-border);
133
- border-bottom: 0;
134
- border-radius: var(--ol-radius) var(--ol-radius) 0 0;
135
- background: var(--ol-surface);
136
- font: inherit;
137
- position: relative;
138
- z-index: var(--ol-z);
139
- }
140
-
141
- .ol-editor .ol-group {
142
- display: flex;
143
- flex-wrap: wrap;
144
- align-items: center;
145
- gap: var(--ol-gap);
146
- }
147
-
148
- /* The divider is a BORDER on the group, not a standalone flex item.
149
- As its own element it could wrap onto the trailing edge of a row with nothing
150
- after it -- a stranded line floating at the end of a row. Wrapping begins
151
- around 690-740px, well inside ordinary desktop widths (a CMS sidebar, a
152
- half-width split pane), so this was not a 360px-only edge case.
153
- border-inline-start rather than border-left, so it flips under RTL. */
154
- .ol-editor .ol-group + .ol-group {
155
- border-inline-start: 1px solid var(--ol-border);
156
- padding-inline-start: 5px;
157
- margin-inline-start: 1px;
158
- }
159
-
160
- /* Every property a host reset or \`button {}\` rule is likely to touch is set
161
- here explicitly. Specificity is (0,2,0) via the descendant selector, which
162
- beats a bare element or single-class host rule without resorting to
163
- !important. */
164
- .ol-editor .ol-btn {
165
- box-sizing: border-box;
166
- display: inline-flex;
167
- align-items: center;
168
- justify-content: center;
169
- flex: 0 0 auto;
170
- width: var(--ol-button-size);
171
- height: var(--ol-button-size);
172
- min-width: var(--ol-button-size);
173
- min-height: var(--ol-button-size);
174
- max-width: none;
175
- padding: 0;
176
- margin: 0;
177
- border: 1px solid transparent;
178
- border-radius: var(--ol-radius);
179
- background: transparent;
180
- color: var(--ol-text);
181
- font: inherit;
182
- font-family: var(--ol-font);
183
- font-size: var(--ol-font-size);
184
- font-weight: 400;
185
- line-height: 1;
186
- letter-spacing: normal;
187
- text-transform: none;
188
- text-align: center;
189
- text-decoration: none;
190
- text-shadow: none;
191
- box-shadow: none;
192
- opacity: 1;
193
- cursor: pointer;
194
- appearance: none;
195
- -webkit-appearance: none;
196
- outline-offset: var(--ol-focus-offset);
197
- -webkit-tap-highlight-color: transparent;
198
- transition: background-color 120ms ease, border-color 120ms ease;
199
- }
200
-
201
- .ol-editor .ol-btn:hover {
202
- background: var(--ol-surface-hover);
203
- }
204
-
205
- /* :focus-visible only, so a mouse click does not leave a ring behind, but the
206
- ring is never removed for keyboard users. */
207
- .ol-editor .ol-btn:focus-visible {
208
- outline: var(--ol-focus-width) solid var(--ol-focus);
209
- outline-offset: var(--ol-focus-offset);
210
- }
211
-
212
- /* Pressed state is distinguished from hover by THREE signals, not just colour:
213
- a filled background, a visible border, and an inset shadow that reads as
214
- physically depressed. Colour alone would fail for a colour-blind author and
215
- would be invisible in forced-colours mode. */
216
- .ol-editor .ol-btn[aria-pressed="true"] {
217
- background: var(--ol-surface-active);
218
- border-color: var(--ol-accent);
219
- color: var(--ol-accent);
220
- box-shadow: inset 0 1px 2px rgb(0 0 0 / 12%);
221
- }
222
-
223
- .ol-editor .ol-btn[aria-pressed="true"]:hover {
224
- background: var(--ol-surface-active);
225
- border-color: var(--ol-accent);
226
- }
227
-
228
- /* aria-disabled rather than the disabled attribute: a disabled button is
229
- removed from the roving tabindex and cannot be reached or announced, so an
230
- author using a screen reader cannot discover that the control exists. */
231
- .ol-editor .ol-btn[aria-disabled="true"] {
232
- opacity: 0.4;
233
- cursor: default;
234
- }
235
-
236
- .ol-editor .ol-btn[aria-disabled="true"]:hover {
237
- background: transparent;
238
- }
239
-
240
- .ol-editor .ol-icon {
241
- width: var(--ol-icon-size);
242
- height: var(--ol-icon-size);
243
- display: block;
244
- pointer-events: none;
245
- flex: 0 0 auto;
246
- }
247
-
248
- /* Block-type select. Sized and coloured to sit level with the icon buttons so
249
- it does not read as bolted on, but it stays a native <select> -- a custom
250
- listbox is a large amount of ARIA that would then owe real screen reader
251
- testing to be worth anything. */
252
- .ol-editor .ol-select {
253
- box-sizing: border-box;
254
- height: var(--ol-button-size);
255
- max-width: 11em;
256
- padding: 0 22px 0 6px;
257
- margin: 0;
258
- border: 1px solid var(--ol-border);
259
- border-radius: var(--ol-radius);
260
- background-color: transparent;
261
- background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
262
- linear-gradient(135deg, currentColor 50%, transparent 50%);
263
- background-position: right 10px center, right 6px center;
264
- background-size: 4px 4px, 4px 4px;
265
- background-repeat: no-repeat;
266
- color: var(--ol-text);
267
- font-family: var(--ol-font);
268
- font-size: var(--ol-font-size);
269
- font-weight: 400;
270
- line-height: 1;
271
- text-transform: none;
272
- letter-spacing: normal;
273
- box-shadow: none;
274
- cursor: pointer;
275
- appearance: none;
276
- -webkit-appearance: none;
277
- }
278
-
279
- .ol-editor .ol-select:hover {
280
- background-color: var(--ol-surface-hover);
281
- }
282
-
283
- .ol-editor .ol-select:focus-visible {
284
- outline: var(--ol-focus-width) solid var(--ol-focus);
285
- outline-offset: var(--ol-focus-offset);
286
- }
287
-
288
- /* The option list is painted by the OS, which does not inherit our tokens, so
289
- give it explicit colours or dark mode shows black text on black. */
290
- .ol-editor .ol-select option {
291
- background: var(--ol-surface);
292
- color: var(--ol-text);
293
- }
294
-
295
- .ol-editor .ol-content {
296
- box-sizing: border-box;
297
- border: 1px solid var(--ol-border);
298
- border-radius: 0 0 var(--ol-radius) var(--ol-radius);
299
- background: var(--ol-surface);
300
- }
301
-
302
- /* Deliberately minimal: the content area inherits the host's typography, which
303
- is the entire reason this project does not use Shadow DOM. Only padding and
304
- the focus ring are ours. */
305
- .ol-editor .ol-content .ProseMirror {
306
- padding: 12px;
307
- min-height: 8rem;
308
- outline: none;
309
- }
310
-
311
- .ol-editor .ol-content:focus-within {
312
- outline: 2px solid var(--ol-focus);
313
- outline-offset: -1px;
314
- }
315
-
316
- /* Tables.
317
- These styles live in core, not in the opt-in table plugin, because table
318
- NODES live in core: every deployment reads and renders tables even where
319
- editing them is switched off. Unstyled tables would render as runs of
320
- undelimited text. */
321
- .ol-editor .ol-content .ProseMirror table {
322
- border-collapse: collapse;
323
- table-layout: fixed;
324
- width: 100%;
325
- margin: 0 0 1em;
326
- overflow: hidden;
327
- }
328
-
329
- .ol-editor .ol-content .ProseMirror td,
330
- .ol-editor .ol-content .ProseMirror th {
331
- border: 1px solid var(--ol-border);
332
- padding: 6px 8px;
333
- vertical-align: top;
334
- /* A zero-width cell cannot be clicked into, so it cannot be repaired. */
335
- min-width: 2em;
336
- position: relative;
337
- }
338
-
339
- /* Presentational valign is otherwise beaten by the rule above, which would
340
- make the cell-properties dialog a no-op on screen. */
341
- .ol-editor .ol-content .ProseMirror td[valign="middle"],
342
- .ol-editor .ol-content .ProseMirror th[valign="middle"] { vertical-align: middle; }
343
- .ol-editor .ol-content .ProseMirror td[valign="bottom"],
344
- .ol-editor .ol-content .ProseMirror th[valign="bottom"] { vertical-align: bottom; }
345
- .ol-editor .ol-content .ProseMirror td[valign="baseline"],
346
- .ol-editor .ol-content .ProseMirror th[valign="baseline"] { vertical-align: baseline; }
347
-
348
- .ol-editor .ol-content .ProseMirror th {
349
- background: var(--ol-surface-hover);
350
- font-weight: 600;
351
- text-align: start;
352
- }
353
-
354
- /* prosemirror-tables marks cells in a rectangular selection with this class.
355
- An ::after overlay rather than a background so it composes with a cell that
356
- already has one, and so a header cell still reads as a header. */
357
- .ol-editor .ol-content .ProseMirror .selectedCell::after {
358
- content: "";
359
- position: absolute;
360
- inset: 0;
361
- background: var(--ol-surface-active);
362
- opacity: 0.4;
363
- pointer-events: none;
364
- }
365
-
366
- /* The column resize handle, drawn by prosemirror-tables' columnResizing. */
367
- .ol-editor .ol-content .ProseMirror .column-resize-handle {
368
- position: absolute;
369
- right: -2px;
370
- top: 0;
371
- bottom: 0;
372
- width: 4px;
373
- background: var(--ol-accent);
374
- pointer-events: none;
375
- z-index: 20;
376
- }
377
-
378
- .ol-editor .ol-content .ProseMirror.resize-cursor {
379
- cursor: col-resize;
380
- }
381
-
382
- .ol-editor .ol-content .ProseMirror img.ol-float-left {
383
- float: left;
384
- margin: 0 1em 0.5em 0;
385
- }
386
- .ol-editor .ol-content .ProseMirror img.ol-float-right {
387
- float: right;
388
- margin: 0 0 0.5em 1em;
389
- }
390
- .ol-editor .ol-content .ProseMirror img.ol-align-center {
391
- display: block;
392
- margin: 0 auto 0.5em;
393
- }
394
- .ol-editor .ol-content .ProseMirror figure {
395
- margin: 0 0 1em;
396
- }
397
- .ol-editor .ol-content .ProseMirror figcaption {
398
- font-size: .9em;
399
- opacity: .8;
400
- margin-top: .35em;
401
- }
402
- .ol-editor .ol-content .ProseMirror details {
403
- border: 1px solid var(--ol-border);
404
- border-radius: var(--ol-radius);
405
- padding: .5em .75em;
406
- margin: 0 0 1em;
407
- }
408
- .ol-editor .ol-content .ProseMirror summary {
409
- cursor: pointer;
410
- font-weight: 600;
411
- }
412
- .ol-editor .ol-content .ProseMirror hr.ol-pagebreak {
413
- border: 0;
414
- border-top: 2px dashed var(--ol-border);
415
- margin: 1.5em 0;
416
- }
417
- .ol-editor .ol-content .ProseMirror iframe,
418
- .ol-editor .ol-content .ProseMirror video,
419
- .ol-editor .ol-content .ProseMirror audio {
420
- max-width: 100%;
421
- }
422
-
423
- /* Preserved-but-unrecognised markup, surfaced rather than hidden. */
424
- .ol-editor .ol-content .ProseMirror-selectednode {
425
- outline: 2px solid var(--ol-focus);
426
- outline-offset: 2px;
427
- border-radius: 2px;
428
- }
429
-
430
- .ol-editor .ol-source {
431
- box-sizing: border-box;
432
- display: block;
433
- width: 100%;
434
- min-height: 12rem;
435
- padding: 12px;
436
- border: 1px solid var(--ol-border);
437
- border-radius: 0 0 var(--ol-radius) var(--ol-radius);
438
- background: var(--ol-surface);
439
- color: var(--ol-text);
440
- font-family: var(--ol-font-mono);
441
- font-size: 13px;
442
- line-height: 1.5;
443
- resize: vertical;
444
- white-space: pre-wrap;
445
- }
446
-
447
- /* Directional icons under RTL.
448
- Group order reverses for free with flexbox, but a curved undo arrow does not:
449
- in an RTL document "back" points the other way. Only genuinely directional
450
- icons are flipped -- bold and italic must not be mirrored. */
451
- .ol-editor[dir="rtl"] .ol-icon--directional,
452
- [dir="rtl"] .ol-editor .ol-icon--directional {
453
- transform: scaleX(-1);
454
- }
455
-
456
- /* The announcement region. Visually hidden but not display:none, which would
457
- remove it from the accessibility tree and silence it. */
458
- .ol-editor .ol-live {
459
- position: absolute;
460
- width: 1px;
461
- height: 1px;
462
- margin: -1px;
463
- padding: 0;
464
- overflow: hidden;
465
- clip: rect(0 0 0 0);
466
- clip-path: inset(50%);
467
- white-space: nowrap;
468
- border: 0;
469
- }
470
-
471
- /* Menubar, menus, floating chrome, visual aids, fullscreen, inline. */
472
- .ol-editor .ol-menubar {
473
- display: flex;
474
- flex-wrap: wrap;
475
- gap: var(--ol-gap);
476
- box-sizing: border-box;
477
- margin: 0;
478
- padding: 2px 4px;
479
- border: 1px solid var(--ol-border);
480
- border-bottom: 0;
481
- border-radius: var(--ol-radius) var(--ol-radius) 0 0;
482
- background: var(--ol-surface);
483
- position: relative;
484
- z-index: var(--ol-z);
485
- }
486
- .ol-editor .ol-menubar + .ol-toolbar {
487
- border-radius: 0;
488
- }
489
- .ol-editor .ol-menu-trigger {
490
- box-sizing: border-box;
491
- margin: 0;
492
- padding: 4px 8px;
493
- border: 1px solid transparent;
494
- border-radius: var(--ol-radius);
495
- background: transparent;
496
- color: var(--ol-text);
497
- font: inherit;
498
- font-family: var(--ol-font);
499
- font-size: var(--ol-font-size);
500
- cursor: pointer;
501
- appearance: none;
502
- }
503
- .ol-editor .ol-menu-trigger:hover,
504
- .ol-editor .ol-menu-trigger[aria-expanded="true"] {
505
- background: var(--ol-surface-hover);
506
- }
507
- .ol-editor .ol-menu-trigger:focus-visible {
508
- outline: var(--ol-focus-width) solid var(--ol-focus);
509
- outline-offset: var(--ol-focus-offset);
510
- }
511
- .ol-editor .ol-menu {
512
- position: absolute;
513
- z-index: calc(var(--ol-z) + 20);
514
- min-width: 12rem;
515
- margin: 0;
516
- padding: 4px;
517
- border: 1px solid var(--ol-border);
518
- border-radius: var(--ol-radius);
519
- background: var(--ol-surface);
520
- box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
521
- }
522
- .ol-editor .ol-menu-item {
523
- display: block;
524
- box-sizing: border-box;
525
- width: 100%;
526
- margin: 0;
527
- padding: 6px 10px;
528
- border: 0;
529
- border-radius: var(--ol-radius);
530
- background: transparent;
531
- color: var(--ol-text);
532
- font: inherit;
533
- font-family: var(--ol-font);
534
- font-size: var(--ol-font-size);
535
- text-align: start;
536
- cursor: pointer;
537
- appearance: none;
538
- }
539
- .ol-editor .ol-menu-item:hover,
540
- .ol-editor .ol-menu-item:focus-visible {
541
- background: var(--ol-surface-hover);
542
- outline: none;
543
- }
544
- .ol-editor .ol-menu-item[aria-disabled="true"] {
545
- opacity: 0.4;
546
- cursor: default;
547
- }
548
- .ol-editor .ol-menu-sep {
549
- height: 1px;
550
- margin: 4px 0;
551
- background: var(--ol-border);
552
- }
553
- .ol-editor .ol-toolbar.ol-floating {
554
- position: absolute;
555
- flex-wrap: nowrap;
556
- border: 1px solid var(--ol-border);
557
- border-radius: var(--ol-radius);
558
- box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
559
- z-index: calc(var(--ol-z) + 10);
560
- }
561
- .ol-editor .ol-toolbar.ol-toolbar--overflow {
562
- flex-wrap: nowrap;
563
- overflow: hidden;
564
- }
565
- .ol-editor.ol-visual-aids .ol-empty-block {
566
- outline: 1px dashed var(--ol-border);
567
- outline-offset: 2px;
568
- min-height: 1.2em;
569
- }
570
- .ol-editor.ol-visual-aids .ol-nbsp {
571
- background: color-mix(in srgb, var(--ol-accent) 25%, transparent);
572
- box-shadow: inset 0 -1px 0 var(--ol-accent);
573
- }
574
- .ol-editor.ol-visual-aids .ol-hidden-structure {
575
- outline: 1px dotted var(--ol-accent);
576
- outline-offset: 2px;
577
- }
578
- .ol-editor .ol-noneditable {
579
- cursor: default;
580
- background: repeating-linear-gradient(
581
- -45deg,
582
- transparent,
583
- transparent 6px,
584
- color-mix(in srgb, var(--ol-border) 35%, transparent) 6px,
585
- color-mix(in srgb, var(--ol-border) 35%, transparent) 7px
586
- );
587
- }
588
- .ol-editor.ol-fullscreen {
589
- position: fixed;
590
- inset: 0;
591
- z-index: 2147483000;
592
- margin: 0;
593
- border-radius: 0;
594
- background: var(--ol-surface);
595
- display: flex;
596
- flex-direction: column;
597
- }
598
- .ol-editor.ol-fullscreen .ol-content,
599
- .ol-editor.ol-fullscreen .ol-source {
600
- flex: 1 1 auto;
601
- min-height: 0;
602
- overflow: auto;
603
- }
604
- .ol-editor.ol-autoresize .ol-content .ProseMirror {
605
- overflow: hidden;
606
- }
607
- .ol-editor.ol-inline:not(.ol-inline-active) .ol-toolbar,
608
- .ol-editor.ol-inline:not(.ol-inline-active) .ol-menubar {
609
- position: absolute;
610
- width: 1px;
611
- height: 1px;
612
- overflow: hidden;
613
- clip: rect(0 0 0 0);
614
- clip-path: inset(50%);
615
- }
616
- .ol-editor.ol-inline .ol-content {
617
- border-radius: var(--ol-radius);
618
- }
619
- .ol-help-table {
620
- width: 100%;
621
- border-collapse: collapse;
622
- font: inherit;
623
- }
624
- .ol-help-table th,
625
- .ol-help-table td {
626
- padding: 4px 8px;
627
- text-align: start;
628
- vertical-align: top;
629
- border-bottom: 1px solid var(--openleaf-color-border, #d1d9e0);
630
- }
631
- .ol-help-table th {
632
- font-weight: 600;
633
- white-space: nowrap;
634
- }
635
-
636
- /* Coarse pointers get a larger target. WCAG 2.2 SC 2.5.8 asks for 24x24 CSS px
637
- minimum; 32 clears that on a mouse and 40 is comfortable on a thumb. */
638
- @media (pointer: coarse) {
639
- .ol-editor {
640
- --ol-button-size: var(--openleaf-button-size, 40px);
641
- --ol-gap: var(--openleaf-gap, 4px);
642
- }
643
- }
644
-
645
- @media (prefers-reduced-motion: reduce) {
646
- .ol-editor .ol-btn {
647
- transition: none;
648
- }
649
- }
650
-
651
- /* Forced colours (Windows high contrast) replaces our palette wholesale. The
652
- pressed state must not depend on a background we no longer control, so it is
653
- re-expressed as a border, which the mode preserves. */
654
- @media (forced-colors: active) {
655
- .ol-editor .ol-btn {
656
- border-color: ButtonBorder;
657
- color: ButtonText;
658
- }
659
- .ol-editor .ol-btn[aria-pressed="true"] {
660
- border-color: Highlight;
661
- color: Highlight;
662
- box-shadow: none;
663
- }
664
- .ol-editor .ol-btn:focus-visible {
665
- outline-color: Highlight;
666
- }
667
- .ol-editor .ol-btn[aria-disabled="true"] {
668
- color: GrayText;
669
- opacity: 1;
670
- }
671
- }
672
- `;
98
+ import { CSS } from './css.js';
99
+ export { CSS } from './css.js';
673
100
  let externallyProvided = false;
674
101
  /**
675
102
  * Declare that the integrator has linked `openleaf.css` themselves, so no
@@ -679,7 +106,10 @@ export function markStylesExternal() {
679
106
  externallyProvided = true;
680
107
  }
681
108
  const injected = new WeakSet();
682
- const registered = new Map();
109
+ // WeakMap, like its sibling above: a strong Map here pins every Document this
110
+ // module has ever styled -- every iframe, every closed print preview -- for the
111
+ // life of the page. Only get/set are used, so nothing needs to iterate it.
112
+ const registered = new WeakMap();
683
113
  let warned = false;
684
114
  /**
685
115
  * Attach a stylesheet through the CSP-safe path.
@@ -706,9 +136,19 @@ export function registerStyles(css, target) {
706
136
  // CSP gates resources *parsed as style* -- <style> elements, style attributes,
707
137
  // linked stylesheets. A CSSOM object attached through adoptedStyleSheets never
708
138
  // passes through that gate, by design rather than by loophole.
709
- if (typeof CSSStyleSheet !== 'undefined' && 'adoptedStyleSheets' in Document.prototype) {
139
+ //
140
+ // The constructor comes from the TARGET document's own window, and the
141
+ // capability is probed on the target rather than on this module's realm. A
142
+ // constructed sheet carries the document it was constructed for, and
143
+ // `adoptedStyleSheets` throws NotAllowedError for a sheet belonging to another
144
+ // one -- so `new CSSStyleSheet()` here, resolved from whichever realm this
145
+ // module happens to be loaded in, could never style an iframe or a print view.
146
+ // Confirmed in all three engines: top-realm sheet -> NotAllowedError, sheet
147
+ // built through the frame's own window -> adopted and applied.
148
+ const view = doc.defaultView;
149
+ if (view?.CSSStyleSheet && 'adoptedStyleSheets' in doc) {
710
150
  try {
711
- const sheet = new CSSStyleSheet();
151
+ const sheet = new view.CSSStyleSheet();
712
152
  sheet.replaceSync(css);
713
153
  doc.adoptedStyleSheets = [...doc.adoptedStyleSheets, sheet];
714
154
  seen.add(css);