@openleaf-editor/ui 0.1.0-beta.0 → 0.1.0-beta.2
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/dist/content-css.d.ts +13 -0
- package/dist/content-css.d.ts.map +1 -0
- package/dist/content-css.js +57 -0
- package/dist/content-css.js.map +1 -0
- package/dist/dialog.d.ts +87 -2
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +358 -68
- package/dist/dialog.js.map +1 -1
- package/dist/floating.d.ts +25 -0
- package/dist/floating.d.ts.map +1 -0
- package/dist/floating.js +82 -0
- package/dist/floating.js.map +1 -0
- package/dist/help.d.ts +9 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +73 -0
- package/dist/help.js.map +1 -0
- package/dist/i18n.d.ts +31 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +89 -0
- package/dist/i18n.js.map +1 -0
- package/dist/icons.d.ts +1 -1
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +17 -1
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/items.d.ts +2 -0
- package/dist/items.d.ts.map +1 -1
- package/dist/items.js +81 -4
- package/dist/items.js.map +1 -1
- package/dist/menu.d.ts +56 -0
- package/dist/menu.d.ts.map +1 -0
- package/dist/menu.js +360 -0
- package/dist/menu.js.map +1 -0
- package/dist/openleaf.css +216 -0
- package/dist/overflow.d.ts +17 -0
- package/dist/overflow.d.ts.map +1 -0
- package/dist/overflow.js +138 -0
- package/dist/overflow.js.map +1 -0
- package/dist/pickers.d.ts +43 -0
- package/dist/pickers.d.ts.map +1 -0
- package/dist/pickers.js +52 -0
- package/dist/pickers.js.map +1 -0
- package/dist/registry.d.ts +49 -8
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +14 -0
- package/dist/registry.js.map +1 -1
- package/dist/styles.d.ts +1 -1
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +216 -0
- package/dist/styles.js.map +1 -1
- package/dist/toolbar.d.ts +20 -0
- package/dist/toolbar.d.ts.map +1 -1
- package/dist/toolbar.js +181 -21
- package/dist/toolbar.js.map +1 -1
- package/dist/upload.d.ts +95 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +104 -0
- package/dist/upload.js.map +1 -0
- package/package.json +2 -2
package/dist/menu.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Menubar and popup menus.
|
|
3
|
+
*
|
|
4
|
+
* Built with `role="menubar"` / `role="menu"` rather than a toolbar, because
|
|
5
|
+
* the two widgets have different keyboard contracts: a toolbar is one tab stop
|
|
6
|
+
* of peer buttons, a menubar is a row of menus that open on Down/Enter and
|
|
7
|
+
* close on Escape. Mixing them is what makes "the File menu is also a toolbar
|
|
8
|
+
* button" feel broken to a screen reader.
|
|
9
|
+
*
|
|
10
|
+
* Items are toolbar ids. The same command a button runs is the command a menu
|
|
11
|
+
* item runs, so a host that hides the toolbar still has a complete Edit menu.
|
|
12
|
+
*/
|
|
13
|
+
import type { EditorView } from 'prosemirror-view';
|
|
14
|
+
export interface MenuItemRef {
|
|
15
|
+
id: string;
|
|
16
|
+
/** Override the toolbar item's label. */
|
|
17
|
+
label?: string;
|
|
18
|
+
}
|
|
19
|
+
export type MenuEntry = MenuItemRef | '|';
|
|
20
|
+
export interface MenuSpec {
|
|
21
|
+
id: string;
|
|
22
|
+
label: string;
|
|
23
|
+
items: readonly MenuEntry[];
|
|
24
|
+
}
|
|
25
|
+
export declare const DEFAULT_MENUBAR: readonly MenuSpec[];
|
|
26
|
+
export declare const LINK_CONTEXT_ITEMS: readonly MenuEntry[];
|
|
27
|
+
export declare const IMAGE_CONTEXT_ITEMS: readonly MenuEntry[];
|
|
28
|
+
export declare const TABLE_CONTEXT_ITEMS: readonly MenuEntry[];
|
|
29
|
+
export declare class PopupMenu {
|
|
30
|
+
#private;
|
|
31
|
+
readonly el: HTMLDivElement;
|
|
32
|
+
constructor(host: HTMLElement, doc: Document);
|
|
33
|
+
attach(view: EditorView): void;
|
|
34
|
+
destroy(): void;
|
|
35
|
+
get open(): boolean;
|
|
36
|
+
show(items: readonly MenuEntry[], x: number, y: number, onClose?: () => void): void;
|
|
37
|
+
close(): void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The menus an integrator asked for, in the order they asked for them.
|
|
41
|
+
*
|
|
42
|
+
* `menubar` with no value means "give me the menubar", so an empty list is every
|
|
43
|
+
* default menu. Named ids are honoured as written: `menubar="edit help"` used to
|
|
44
|
+
* render Insert, Format and View as well, because the attribute was read as a
|
|
45
|
+
* boolean and the list thrown away. An unknown id is skipped rather than fatal,
|
|
46
|
+
* so a layout written against a later version degrades instead of breaking.
|
|
47
|
+
*/
|
|
48
|
+
export declare function selectMenus(attr: string | null | undefined, menus?: readonly MenuSpec[]): readonly MenuSpec[];
|
|
49
|
+
export declare class MenuBar {
|
|
50
|
+
#private;
|
|
51
|
+
readonly el: HTMLDivElement;
|
|
52
|
+
constructor(host: HTMLElement, doc: Document, menus?: readonly MenuSpec[], locale?: string | null);
|
|
53
|
+
mount(view: EditorView): void;
|
|
54
|
+
destroy(): void;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../src/menu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAKlD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,GAAG,CAAA;AAEzC,MAAM,WAAW,QAAQ;I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
|
|
2
|
+
* Menubar and popup menus.
|
|
3
|
+
*
|
|
4
|
+
* Built with `role="menubar"` / `role="menu"` rather than a toolbar, because
|
|
5
|
+
* the two widgets have different keyboard contracts: a toolbar is one tab stop
|
|
6
|
+
* of peer buttons, a menubar is a row of menus that open on Down/Enter and
|
|
7
|
+
* close on Escape. Mixing them is what makes "the File menu is also a toolbar
|
|
8
|
+
* button" feel broken to a screen reader.
|
|
9
|
+
*
|
|
10
|
+
* Items are toolbar ids. The same command a button runs is the command a menu
|
|
11
|
+
* item runs, so a host that hides the toolbar still has a complete Edit menu.
|
|
12
|
+
*/
|
|
13
|
+
import { t, withLocale } from './i18n.js';
|
|
14
|
+
import { getToolbarItem } from './registry.js';
|
|
15
|
+
import { ensureStyles } from './styles.js';
|
|
16
|
+
export const DEFAULT_MENUBAR = [
|
|
17
|
+
{
|
|
18
|
+
id: 'edit',
|
|
19
|
+
label: 'Edit',
|
|
20
|
+
items: [
|
|
21
|
+
{ id: 'undo' },
|
|
22
|
+
{ id: 'redo' },
|
|
23
|
+
'|',
|
|
24
|
+
{ id: 'bold' },
|
|
25
|
+
{ id: 'italic' },
|
|
26
|
+
{ id: 'underline' },
|
|
27
|
+
{ id: 'strikethrough' },
|
|
28
|
+
{ id: 'code' },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'insert',
|
|
33
|
+
label: 'Insert',
|
|
34
|
+
items: [{ id: 'link' }, { id: 'image' }, { id: 'horizontalRule' }, { id: 'insertTable' }],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'format',
|
|
38
|
+
label: 'Format',
|
|
39
|
+
items: [
|
|
40
|
+
{ id: 'alignLeft' },
|
|
41
|
+
{ id: 'alignCenter' },
|
|
42
|
+
{ id: 'alignRight' },
|
|
43
|
+
{ id: 'alignJustify' },
|
|
44
|
+
'|',
|
|
45
|
+
{ id: 'bulletList' },
|
|
46
|
+
{ id: 'orderedList' },
|
|
47
|
+
{ id: 'blockquote' },
|
|
48
|
+
{ id: 'codeBlock' },
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'view',
|
|
53
|
+
label: 'View',
|
|
54
|
+
items: [{ id: 'source' }, { id: 'fullscreen' }, { id: 'visualAids' }],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'help',
|
|
58
|
+
label: 'Help',
|
|
59
|
+
items: [{ id: 'help' }],
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
export const LINK_CONTEXT_ITEMS = [{ id: 'link' }, { id: 'unlink' }];
|
|
63
|
+
export const IMAGE_CONTEXT_ITEMS = [{ id: 'image' }];
|
|
64
|
+
export const TABLE_CONTEXT_ITEMS = [
|
|
65
|
+
{ id: 'addRowBefore' },
|
|
66
|
+
{ id: 'addRowAfter' },
|
|
67
|
+
{ id: 'deleteRow' },
|
|
68
|
+
'|',
|
|
69
|
+
{ id: 'addColumnBefore' },
|
|
70
|
+
{ id: 'addColumnAfter' },
|
|
71
|
+
{ id: 'deleteColumn' },
|
|
72
|
+
'|',
|
|
73
|
+
{ id: 'deleteTable' },
|
|
74
|
+
];
|
|
75
|
+
function invoke(spec, view, host) {
|
|
76
|
+
if (host.hasAttribute('readonly'))
|
|
77
|
+
return;
|
|
78
|
+
try {
|
|
79
|
+
if (spec.run) {
|
|
80
|
+
spec.run({ view, host });
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (spec.command) {
|
|
84
|
+
spec.command(view.state, view.dispatch, view);
|
|
85
|
+
view.focus();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
console.error(`@openleaf-editor/ui: menu item "${spec.id}" threw`, error);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function enabled(spec, state, host) {
|
|
93
|
+
if (host.hasAttribute('readonly'))
|
|
94
|
+
return false;
|
|
95
|
+
if (spec.isEnabled) {
|
|
96
|
+
try {
|
|
97
|
+
return spec.isEnabled(state);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (spec.command)
|
|
104
|
+
return spec.command(state);
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
export class PopupMenu {
|
|
108
|
+
el;
|
|
109
|
+
#doc;
|
|
110
|
+
#host;
|
|
111
|
+
#view = null;
|
|
112
|
+
#items = [];
|
|
113
|
+
#onClose;
|
|
114
|
+
constructor(host, doc) {
|
|
115
|
+
this.#host = host;
|
|
116
|
+
this.#doc = doc;
|
|
117
|
+
ensureStyles(doc);
|
|
118
|
+
this.el = doc.createElement('div');
|
|
119
|
+
this.el.className = 'ol-menu';
|
|
120
|
+
this.el.setAttribute('role', 'menu');
|
|
121
|
+
this.el.hidden = true;
|
|
122
|
+
this.el.addEventListener('keydown', this.#onKeydown);
|
|
123
|
+
this.el.addEventListener('click', this.#onClick);
|
|
124
|
+
}
|
|
125
|
+
attach(view) {
|
|
126
|
+
this.#view = view;
|
|
127
|
+
}
|
|
128
|
+
destroy() {
|
|
129
|
+
this.close();
|
|
130
|
+
this.el.removeEventListener('keydown', this.#onKeydown);
|
|
131
|
+
this.el.removeEventListener('click', this.#onClick);
|
|
132
|
+
this.el.remove();
|
|
133
|
+
}
|
|
134
|
+
get open() {
|
|
135
|
+
return !this.el.hidden;
|
|
136
|
+
}
|
|
137
|
+
show(items, x, y, onClose) {
|
|
138
|
+
this.#items = items;
|
|
139
|
+
this.#onClose = onClose;
|
|
140
|
+
this.#render();
|
|
141
|
+
this.el.hidden = false;
|
|
142
|
+
const hostBox = this.#host.getBoundingClientRect();
|
|
143
|
+
this.el.style.left = `${Math.max(0, x - hostBox.left)}px`;
|
|
144
|
+
this.el.style.top = `${Math.max(0, y - hostBox.top)}px`;
|
|
145
|
+
const first = this.el.querySelector('[role="menuitem"]');
|
|
146
|
+
first?.focus();
|
|
147
|
+
}
|
|
148
|
+
close() {
|
|
149
|
+
if (this.el.hidden)
|
|
150
|
+
return;
|
|
151
|
+
this.el.hidden = true;
|
|
152
|
+
this.el.replaceChildren();
|
|
153
|
+
const close = this.#onClose;
|
|
154
|
+
this.#onClose = undefined;
|
|
155
|
+
close?.();
|
|
156
|
+
}
|
|
157
|
+
#render() {
|
|
158
|
+
this.el.replaceChildren();
|
|
159
|
+
const view = this.#view;
|
|
160
|
+
if (!view)
|
|
161
|
+
return;
|
|
162
|
+
for (const entry of this.#items) {
|
|
163
|
+
if (entry === '|') {
|
|
164
|
+
const sep = this.#doc.createElement('div');
|
|
165
|
+
sep.setAttribute('role', 'separator');
|
|
166
|
+
sep.className = 'ol-menu-sep';
|
|
167
|
+
this.el.appendChild(sep);
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
const spec = getToolbarItem(entry.id);
|
|
171
|
+
if (!spec)
|
|
172
|
+
continue;
|
|
173
|
+
const button = this.#doc.createElement('button');
|
|
174
|
+
button.type = 'button';
|
|
175
|
+
button.className = 'ol-menu-item';
|
|
176
|
+
button.setAttribute('role', 'menuitem');
|
|
177
|
+
button.dataset['olId'] = spec.id;
|
|
178
|
+
button.textContent = t(entry.label ?? spec.label);
|
|
179
|
+
const isEnabled = enabled(spec, view.state, this.#host);
|
|
180
|
+
button.setAttribute('aria-disabled', isEnabled ? 'false' : 'true');
|
|
181
|
+
this.el.appendChild(button);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
#onClick = (event) => {
|
|
185
|
+
const target = event.target?.closest('[data-ol-id]');
|
|
186
|
+
if (!target || target.getAttribute('aria-disabled') === 'true')
|
|
187
|
+
return;
|
|
188
|
+
const spec = getToolbarItem(target.dataset['olId'] ?? '');
|
|
189
|
+
const view = this.#view;
|
|
190
|
+
if (!spec || !view)
|
|
191
|
+
return;
|
|
192
|
+
this.close();
|
|
193
|
+
invoke(spec, view, this.#host);
|
|
194
|
+
};
|
|
195
|
+
#onKeydown = (event) => {
|
|
196
|
+
const items = [...this.el.querySelectorAll('[role="menuitem"]')];
|
|
197
|
+
const index = items.indexOf(event.target);
|
|
198
|
+
if (event.key === 'Escape') {
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
this.close();
|
|
201
|
+
this.#view?.focus();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
205
|
+
event.preventDefault();
|
|
206
|
+
if (items.length === 0)
|
|
207
|
+
return;
|
|
208
|
+
const delta = event.key === 'ArrowDown' ? 1 : -1;
|
|
209
|
+
const next = items[(index + delta + items.length) % items.length];
|
|
210
|
+
next?.focus();
|
|
211
|
+
}
|
|
212
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
213
|
+
event.preventDefault();
|
|
214
|
+
event.target.click();
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* The menus an integrator asked for, in the order they asked for them.
|
|
220
|
+
*
|
|
221
|
+
* `menubar` with no value means "give me the menubar", so an empty list is every
|
|
222
|
+
* default menu. Named ids are honoured as written: `menubar="edit help"` used to
|
|
223
|
+
* render Insert, Format and View as well, because the attribute was read as a
|
|
224
|
+
* boolean and the list thrown away. An unknown id is skipped rather than fatal,
|
|
225
|
+
* so a layout written against a later version degrades instead of breaking.
|
|
226
|
+
*/
|
|
227
|
+
export function selectMenus(attr, menus = DEFAULT_MENUBAR) {
|
|
228
|
+
const ids = (attr ?? '')
|
|
229
|
+
.split(/[\s,]+/)
|
|
230
|
+
.map((id) => id.trim())
|
|
231
|
+
.filter((id) => id !== '');
|
|
232
|
+
if (ids.length === 0)
|
|
233
|
+
return menus;
|
|
234
|
+
const byId = new Map(menus.map((menu) => [menu.id, menu]));
|
|
235
|
+
const picked = [];
|
|
236
|
+
for (const id of ids) {
|
|
237
|
+
const menu = byId.get(id);
|
|
238
|
+
if (menu && !picked.includes(menu))
|
|
239
|
+
picked.push(menu);
|
|
240
|
+
}
|
|
241
|
+
return picked;
|
|
242
|
+
}
|
|
243
|
+
export class MenuBar {
|
|
244
|
+
el;
|
|
245
|
+
#doc;
|
|
246
|
+
#host;
|
|
247
|
+
#view = null;
|
|
248
|
+
#menus;
|
|
249
|
+
#popup;
|
|
250
|
+
#openId = null;
|
|
251
|
+
#locale;
|
|
252
|
+
constructor(host, doc, menus = DEFAULT_MENUBAR, locale = null) {
|
|
253
|
+
this.#host = host;
|
|
254
|
+
this.#doc = doc;
|
|
255
|
+
this.#menus = menus;
|
|
256
|
+
this.#locale = locale;
|
|
257
|
+
ensureStyles(doc);
|
|
258
|
+
this.el = doc.createElement('div');
|
|
259
|
+
this.el.className = 'ol-menubar';
|
|
260
|
+
this.el.setAttribute('role', 'menubar');
|
|
261
|
+
withLocale(locale, () => {
|
|
262
|
+
this.el.setAttribute('aria-label', t('Editor menu'));
|
|
263
|
+
});
|
|
264
|
+
this.#popup = new PopupMenu(host, doc);
|
|
265
|
+
this.#render();
|
|
266
|
+
this.el.addEventListener('keydown', this.#onKeydown);
|
|
267
|
+
doc.addEventListener('pointerdown', this.#onPointerDown, true);
|
|
268
|
+
}
|
|
269
|
+
mount(view) {
|
|
270
|
+
this.#view = view;
|
|
271
|
+
this.#popup.attach(view);
|
|
272
|
+
if (!this.#popup.el.isConnected)
|
|
273
|
+
this.#host.appendChild(this.#popup.el);
|
|
274
|
+
}
|
|
275
|
+
destroy() {
|
|
276
|
+
this.#doc.removeEventListener('pointerdown', this.#onPointerDown, true);
|
|
277
|
+
this.el.removeEventListener('keydown', this.#onKeydown);
|
|
278
|
+
this.#popup.destroy();
|
|
279
|
+
}
|
|
280
|
+
#render() {
|
|
281
|
+
withLocale(this.#locale, () => this.#renderScoped());
|
|
282
|
+
}
|
|
283
|
+
#renderScoped() {
|
|
284
|
+
this.el.replaceChildren();
|
|
285
|
+
for (const menu of this.#menus) {
|
|
286
|
+
const button = this.#doc.createElement('button');
|
|
287
|
+
button.type = 'button';
|
|
288
|
+
button.className = 'ol-menu-trigger';
|
|
289
|
+
button.setAttribute('role', 'menuitem');
|
|
290
|
+
button.setAttribute('aria-haspopup', 'true');
|
|
291
|
+
button.setAttribute('aria-expanded', 'false');
|
|
292
|
+
button.dataset['olMenu'] = menu.id;
|
|
293
|
+
button.textContent = t(menu.label);
|
|
294
|
+
button.addEventListener('click', () => this.#toggle(menu, button));
|
|
295
|
+
this.el.appendChild(button);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
#toggle(menu, trigger) {
|
|
299
|
+
if (this.#openId === menu.id && this.#popup.open) {
|
|
300
|
+
this.#close();
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
this.#open(menu, trigger);
|
|
304
|
+
}
|
|
305
|
+
#open(menu, trigger) {
|
|
306
|
+
this.#close();
|
|
307
|
+
this.#openId = menu.id;
|
|
308
|
+
trigger.setAttribute('aria-expanded', 'true');
|
|
309
|
+
const rect = trigger.getBoundingClientRect();
|
|
310
|
+
this.#popup.show(menu.items, rect.left, rect.bottom + 2, () => {
|
|
311
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
312
|
+
this.#openId = null;
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
#close() {
|
|
316
|
+
this.#popup.close();
|
|
317
|
+
for (const button of this.el.querySelectorAll('[aria-expanded]')) {
|
|
318
|
+
button.setAttribute('aria-expanded', 'false');
|
|
319
|
+
}
|
|
320
|
+
this.#openId = null;
|
|
321
|
+
}
|
|
322
|
+
#onKeydown = (event) => {
|
|
323
|
+
const triggers = [...this.el.querySelectorAll('.ol-menu-trigger')];
|
|
324
|
+
const index = triggers.indexOf(event.target);
|
|
325
|
+
if (index < 0)
|
|
326
|
+
return;
|
|
327
|
+
if (event.key === 'ArrowRight' || event.key === 'ArrowLeft') {
|
|
328
|
+
event.preventDefault();
|
|
329
|
+
const delta = event.key === 'ArrowRight' ? 1 : -1;
|
|
330
|
+
const next = triggers[(index + delta + triggers.length) % triggers.length];
|
|
331
|
+
next?.focus();
|
|
332
|
+
if (this.#popup.open && next) {
|
|
333
|
+
const menu = this.#menus.find((m) => m.id === next.dataset['olMenu']);
|
|
334
|
+
if (menu)
|
|
335
|
+
this.#open(menu, next);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (event.key === 'ArrowDown' || event.key === 'Enter' || event.key === ' ') {
|
|
339
|
+
event.preventDefault();
|
|
340
|
+
const menu = this.#menus.find((m) => m.id === triggers[index]?.dataset['olMenu']);
|
|
341
|
+
const trigger = triggers[index];
|
|
342
|
+
if (menu && trigger)
|
|
343
|
+
this.#open(menu, trigger);
|
|
344
|
+
}
|
|
345
|
+
if (event.key === 'Escape') {
|
|
346
|
+
event.preventDefault();
|
|
347
|
+
this.#close();
|
|
348
|
+
this.#view?.focus();
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
#onPointerDown = (event) => {
|
|
352
|
+
if (!this.#popup.open)
|
|
353
|
+
return;
|
|
354
|
+
const target = event.target;
|
|
355
|
+
if (target && (this.el.contains(target) || this.#popup.el.contains(target)))
|
|
356
|
+
return;
|
|
357
|
+
this.#close();
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
//# sourceMappingURL=menu.js.map
|
package/dist/menu.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../src/menu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,cAAc,EAAwB,MAAM,eAAe,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAgB1C,MAAM,CAAC,MAAM,eAAe,GAAwB;IAClD;QACE,EAAE,EAAE,MAAM;QACV,KAAK,EAAE,MAAM;QACb,KAAK,EAAE;YACL,EAAE,EAAE,EAAE,MAAM,EAAE;YACd,EAAE,EAAE,EAAE,MAAM,EAAE;YACd,GAAG;YACH,EAAE,E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AAC,cAAc,EAAE,CAAA;YACtB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAA;YACjF,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;YAC/B,IAAI,IAAI,IAAI,OAAO;gBAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAChD,CAAC;QACD,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC3B,KAAK,CAAC,cAAc,EAAE,CAAA;YACtB,IAAI,CAAC,MAAM,EAAE,CAAA;YACb,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,CAAA;QACrB,CAAC;IACH,CAAC,CAAA;IAED,cAAc,GAAG,CAAC,KAAmB,EAAQ,EAAE;QAC7C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;YAAE,OAAM;QAC7B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAqB,CAAA;QAC1C,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAAE,OAAM;QACnF,IAAI,CAAC,MAAM,EAAE,CAAA;IACf,CAAC,CAAA;CACF"}
|
package/dist/openleaf.css
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
--ol-focus-offset: var(--openleaf-focus-offset, 1px);
|
|
32
32
|
|
|
33
33
|
display: block;
|
|
34
|
+
position: relative;
|
|
34
35
|
color: var(--ol-text);
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -306,6 +307,15 @@
|
|
|
306
307
|
position: relative;
|
|
307
308
|
}
|
|
308
309
|
|
|
310
|
+
/* Presentational valign is otherwise beaten by the rule above, which would
|
|
311
|
+
make the cell-properties dialog a no-op on screen. */
|
|
312
|
+
.ol-editor .ol-content .ProseMirror td[valign="middle"],
|
|
313
|
+
.ol-editor .ol-content .ProseMirror th[valign="middle"] { vertical-align: middle; }
|
|
314
|
+
.ol-editor .ol-content .ProseMirror td[valign="bottom"],
|
|
315
|
+
.ol-editor .ol-content .ProseMirror th[valign="bottom"] { vertical-align: bottom; }
|
|
316
|
+
.ol-editor .ol-content .ProseMirror td[valign="baseline"],
|
|
317
|
+
.ol-editor .ol-content .ProseMirror th[valign="baseline"] { vertical-align: baseline; }
|
|
318
|
+
|
|
309
319
|
.ol-editor .ol-content .ProseMirror th {
|
|
310
320
|
background: var(--ol-surface-hover);
|
|
311
321
|
font-weight: 600;
|
|
@@ -340,6 +350,47 @@
|
|
|
340
350
|
cursor: col-resize;
|
|
341
351
|
}
|
|
342
352
|
|
|
353
|
+
.ol-editor .ol-content .ProseMirror img.ol-float-left {
|
|
354
|
+
float: left;
|
|
355
|
+
margin: 0 1em 0.5em 0;
|
|
356
|
+
}
|
|
357
|
+
.ol-editor .ol-content .ProseMirror img.ol-float-right {
|
|
358
|
+
float: right;
|
|
359
|
+
margin: 0 0 0.5em 1em;
|
|
360
|
+
}
|
|
361
|
+
.ol-editor .ol-content .ProseMirror img.ol-align-center {
|
|
362
|
+
display: block;
|
|
363
|
+
margin: 0 auto 0.5em;
|
|
364
|
+
}
|
|
365
|
+
.ol-editor .ol-content .ProseMirror figure {
|
|
366
|
+
margin: 0 0 1em;
|
|
367
|
+
}
|
|
368
|
+
.ol-editor .ol-content .ProseMirror figcaption {
|
|
369
|
+
font-size: .9em;
|
|
370
|
+
opacity: .8;
|
|
371
|
+
margin-top: .35em;
|
|
372
|
+
}
|
|
373
|
+
.ol-editor .ol-content .ProseMirror details {
|
|
374
|
+
border: 1px solid var(--ol-border);
|
|
375
|
+
border-radius: var(--ol-radius);
|
|
376
|
+
padding: .5em .75em;
|
|
377
|
+
margin: 0 0 1em;
|
|
378
|
+
}
|
|
379
|
+
.ol-editor .ol-content .ProseMirror summary {
|
|
380
|
+
cursor: pointer;
|
|
381
|
+
font-weight: 600;
|
|
382
|
+
}
|
|
383
|
+
.ol-editor .ol-content .ProseMirror hr.ol-pagebreak {
|
|
384
|
+
border: 0;
|
|
385
|
+
border-top: 2px dashed var(--ol-border);
|
|
386
|
+
margin: 1.5em 0;
|
|
387
|
+
}
|
|
388
|
+
.ol-editor .ol-content .ProseMirror iframe,
|
|
389
|
+
.ol-editor .ol-content .ProseMirror video,
|
|
390
|
+
.ol-editor .ol-content .ProseMirror audio {
|
|
391
|
+
max-width: 100%;
|
|
392
|
+
}
|
|
393
|
+
|
|
343
394
|
/* Preserved-but-unrecognised markup, surfaced rather than hidden. */
|
|
344
395
|
.ol-editor .ol-content .ProseMirror-selectednode {
|
|
345
396
|
outline: 2px solid var(--ol-focus);
|
|
@@ -388,6 +439,171 @@
|
|
|
388
439
|
border: 0;
|
|
389
440
|
}
|
|
390
441
|
|
|
442
|
+
/* Menubar, menus, floating chrome, visual aids, fullscreen, inline. */
|
|
443
|
+
.ol-editor .ol-menubar {
|
|
444
|
+
display: flex;
|
|
445
|
+
flex-wrap: wrap;
|
|
446
|
+
gap: var(--ol-gap);
|
|
447
|
+
box-sizing: border-box;
|
|
448
|
+
margin: 0;
|
|
449
|
+
padding: 2px 4px;
|
|
450
|
+
border: 1px solid var(--ol-border);
|
|
451
|
+
border-bottom: 0;
|
|
452
|
+
border-radius: var(--ol-radius) var(--ol-radius) 0 0;
|
|
453
|
+
background: var(--ol-surface);
|
|
454
|
+
position: relative;
|
|
455
|
+
z-index: var(--ol-z);
|
|
456
|
+
}
|
|
457
|
+
.ol-editor .ol-menubar + .ol-toolbar {
|
|
458
|
+
border-radius: 0;
|
|
459
|
+
}
|
|
460
|
+
.ol-editor .ol-menu-trigger {
|
|
461
|
+
box-sizing: border-box;
|
|
462
|
+
margin: 0;
|
|
463
|
+
padding: 4px 8px;
|
|
464
|
+
border: 1px solid transparent;
|
|
465
|
+
border-radius: var(--ol-radius);
|
|
466
|
+
background: transparent;
|
|
467
|
+
color: var(--ol-text);
|
|
468
|
+
font: inherit;
|
|
469
|
+
font-family: var(--ol-font);
|
|
470
|
+
font-size: var(--ol-font-size);
|
|
471
|
+
cursor: pointer;
|
|
472
|
+
appearance: none;
|
|
473
|
+
}
|
|
474
|
+
.ol-editor .ol-menu-trigger:hover,
|
|
475
|
+
.ol-editor .ol-menu-trigger[aria-expanded="true"] {
|
|
476
|
+
background: var(--ol-surface-hover);
|
|
477
|
+
}
|
|
478
|
+
.ol-editor .ol-menu-trigger:focus-visible {
|
|
479
|
+
outline: var(--ol-focus-width) solid var(--ol-focus);
|
|
480
|
+
outline-offset: var(--ol-focus-offset);
|
|
481
|
+
}
|
|
482
|
+
.ol-editor .ol-menu {
|
|
483
|
+
position: absolute;
|
|
484
|
+
z-index: calc(var(--ol-z) + 20);
|
|
485
|
+
min-width: 12rem;
|
|
486
|
+
margin: 0;
|
|
487
|
+
padding: 4px;
|
|
488
|
+
border: 1px solid var(--ol-border);
|
|
489
|
+
border-radius: var(--ol-radius);
|
|
490
|
+
background: var(--ol-surface);
|
|
491
|
+
box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
|
|
492
|
+
}
|
|
493
|
+
.ol-editor .ol-menu-item {
|
|
494
|
+
display: block;
|
|
495
|
+
box-sizing: border-box;
|
|
496
|
+
width: 100%;
|
|
497
|
+
margin: 0;
|
|
498
|
+
padding: 6px 10px;
|
|
499
|
+
border: 0;
|
|
500
|
+
border-radius: var(--ol-radius);
|
|
501
|
+
background: transparent;
|
|
502
|
+
color: var(--ol-text);
|
|
503
|
+
font: inherit;
|
|
504
|
+
font-family: var(--ol-font);
|
|
505
|
+
font-size: var(--ol-font-size);
|
|
506
|
+
text-align: start;
|
|
507
|
+
cursor: pointer;
|
|
508
|
+
appearance: none;
|
|
509
|
+
}
|
|
510
|
+
.ol-editor .ol-menu-item:hover,
|
|
511
|
+
.ol-editor .ol-menu-item:focus-visible {
|
|
512
|
+
background: var(--ol-surface-hover);
|
|
513
|
+
outline: none;
|
|
514
|
+
}
|
|
515
|
+
.ol-editor .ol-menu-item[aria-disabled="true"] {
|
|
516
|
+
opacity: 0.4;
|
|
517
|
+
cursor: default;
|
|
518
|
+
}
|
|
519
|
+
.ol-editor .ol-menu-sep {
|
|
520
|
+
height: 1px;
|
|
521
|
+
margin: 4px 0;
|
|
522
|
+
background: var(--ol-border);
|
|
523
|
+
}
|
|
524
|
+
.ol-editor .ol-toolbar.ol-floating {
|
|
525
|
+
position: absolute;
|
|
526
|
+
flex-wrap: nowrap;
|
|
527
|
+
border: 1px solid var(--ol-border);
|
|
528
|
+
border-radius: var(--ol-radius);
|
|
529
|
+
box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
|
|
530
|
+
z-index: calc(var(--ol-z) + 10);
|
|
531
|
+
}
|
|
532
|
+
.ol-editor .ol-toolbar.ol-toolbar--overflow {
|
|
533
|
+
flex-wrap: nowrap;
|
|
534
|
+
overflow: hidden;
|
|
535
|
+
}
|
|
536
|
+
.ol-editor.ol-visual-aids .ol-empty-block {
|
|
537
|
+
outline: 1px dashed var(--ol-border);
|
|
538
|
+
outline-offset: 2px;
|
|
539
|
+
min-height: 1.2em;
|
|
540
|
+
}
|
|
541
|
+
.ol-editor.ol-visual-aids .ol-nbsp {
|
|
542
|
+
background: color-mix(in srgb, var(--ol-accent) 25%, transparent);
|
|
543
|
+
box-shadow: inset 0 -1px 0 var(--ol-accent);
|
|
544
|
+
}
|
|
545
|
+
.ol-editor.ol-visual-aids .ol-hidden-structure {
|
|
546
|
+
outline: 1px dotted var(--ol-accent);
|
|
547
|
+
outline-offset: 2px;
|
|
548
|
+
}
|
|
549
|
+
.ol-editor .ol-noneditable {
|
|
550
|
+
cursor: default;
|
|
551
|
+
background: repeating-linear-gradient(
|
|
552
|
+
-45deg,
|
|
553
|
+
transparent,
|
|
554
|
+
transparent 6px,
|
|
555
|
+
color-mix(in srgb, var(--ol-border) 35%, transparent) 6px,
|
|
556
|
+
color-mix(in srgb, var(--ol-border) 35%, transparent) 7px
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
.ol-editor.ol-fullscreen {
|
|
560
|
+
position: fixed;
|
|
561
|
+
inset: 0;
|
|
562
|
+
z-index: 2147483000;
|
|
563
|
+
margin: 0;
|
|
564
|
+
border-radius: 0;
|
|
565
|
+
background: var(--ol-surface);
|
|
566
|
+
display: flex;
|
|
567
|
+
flex-direction: column;
|
|
568
|
+
}
|
|
569
|
+
.ol-editor.ol-fullscreen .ol-content,
|
|
570
|
+
.ol-editor.ol-fullscreen .ol-source {
|
|
571
|
+
flex: 1 1 auto;
|
|
572
|
+
min-height: 0;
|
|
573
|
+
overflow: auto;
|
|
574
|
+
}
|
|
575
|
+
.ol-editor.ol-autoresize .ol-content .ProseMirror {
|
|
576
|
+
overflow: hidden;
|
|
577
|
+
}
|
|
578
|
+
.ol-editor.ol-inline:not(.ol-inline-active) .ol-toolbar,
|
|
579
|
+
.ol-editor.ol-inline:not(.ol-inline-active) .ol-menubar {
|
|
580
|
+
position: absolute;
|
|
581
|
+
width: 1px;
|
|
582
|
+
height: 1px;
|
|
583
|
+
overflow: hidden;
|
|
584
|
+
clip: rect(0 0 0 0);
|
|
585
|
+
clip-path: inset(50%);
|
|
586
|
+
}
|
|
587
|
+
.ol-editor.ol-inline .ol-content {
|
|
588
|
+
border-radius: var(--ol-radius);
|
|
589
|
+
}
|
|
590
|
+
.ol-help-table {
|
|
591
|
+
width: 100%;
|
|
592
|
+
border-collapse: collapse;
|
|
593
|
+
font: inherit;
|
|
594
|
+
}
|
|
595
|
+
.ol-help-table th,
|
|
596
|
+
.ol-help-table td {
|
|
597
|
+
padding: 4px 8px;
|
|
598
|
+
text-align: start;
|
|
599
|
+
vertical-align: top;
|
|
600
|
+
border-bottom: 1px solid var(--openleaf-color-border, #d1d9e0);
|
|
601
|
+
}
|
|
602
|
+
.ol-help-table th {
|
|
603
|
+
font-weight: 600;
|
|
604
|
+
white-space: nowrap;
|
|
605
|
+
}
|
|
606
|
+
|
|
391
607
|
/* Coarse pointers get a larger target. WCAG 2.2 SC 2.5.8 asks for 24x24 CSS px
|
|
392
608
|
minimum; 32 clears that on a mouse and 40 is comfortable on a thumb. */
|
|
393
609
|
@media (pointer: coarse) {
|