@openleaf-editor/ui 0.1.0-beta.1 → 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 +66 -19
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +198 -51
- 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.map +1 -1
- package/dist/icons.js +4 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- 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 +43 -3
- 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/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 +105 -17
- package/dist/toolbar.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Floating toolbars: one for a non-empty selection, one for an empty block
|
|
3
|
+
* that is waiting to be filled.
|
|
4
|
+
*
|
|
5
|
+
* They reuse the same `Toolbar` class as the main bar so the keyboard model,
|
|
6
|
+
* live region and item registry stay in one place. Positioning is the only
|
|
7
|
+
* extra job, and it is deliberately pointer-driven: a keyboard user already
|
|
8
|
+
* has Alt+F10 for the main toolbar, and a second bar that jumps around under
|
|
9
|
+
* arrow keys is a focus trap waiting to happen.
|
|
10
|
+
*/
|
|
11
|
+
import type { EditorState } from 'prosemirror-state';
|
|
12
|
+
import type { EditorView } from 'prosemirror-view';
|
|
13
|
+
export declare const DEFAULT_SELECTION_LAYOUT = "bold italic underline | link";
|
|
14
|
+
export declare const DEFAULT_INSERT_LAYOUT = "link image horizontalRule";
|
|
15
|
+
export declare class FloatingToolbars {
|
|
16
|
+
#private;
|
|
17
|
+
constructor(host: HTMLElement, doc: Document, options: {
|
|
18
|
+
selectionLayout?: string | null;
|
|
19
|
+
insertLayout?: string | null;
|
|
20
|
+
});
|
|
21
|
+
mount(view: EditorView): void;
|
|
22
|
+
update(state: EditorState): void;
|
|
23
|
+
destroy(): void;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=floating.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floating.d.ts","sourceRoot":"","sources":["../src/floating.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlD,eAAO,MAAM,wBAAwB,iCAAiC,CAAA;AACtE,eAAO,MAAM,qBAAqB,8BAA8B,CAAA;AAEhE,qBAAa,gBAAgB;;gBAQzB,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,QAAQ,EACb,OAAO,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;IAsB5E,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAM7B,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAMhC,OAAO,IAAI,IAAI;CA8BhB"}
|
package/dist/floating.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Floating toolbars: one for a non-empty selection, one for an empty block
|
|
3
|
+
* that is waiting to be filled.
|
|
4
|
+
*
|
|
5
|
+
* They reuse the same `Toolbar` class as the main bar so the keyboard model,
|
|
6
|
+
* live region and item registry stay in one place. Positioning is the only
|
|
7
|
+
* extra job, and it is deliberately pointer-driven: a keyboard user already
|
|
8
|
+
* has Alt+F10 for the main toolbar, and a second bar that jumps around under
|
|
9
|
+
* arrow keys is a focus trap waiting to happen.
|
|
10
|
+
*/
|
|
11
|
+
import { Toolbar } from './toolbar.js';
|
|
12
|
+
export const DEFAULT_SELECTION_LAYOUT = 'bold italic underline | link';
|
|
13
|
+
export const DEFAULT_INSERT_LAYOUT = 'link image horizontalRule';
|
|
14
|
+
export class FloatingToolbars {
|
|
15
|
+
#host;
|
|
16
|
+
#doc;
|
|
17
|
+
#view = null;
|
|
18
|
+
#selection;
|
|
19
|
+
#insert;
|
|
20
|
+
constructor(host, doc, options) {
|
|
21
|
+
this.#host = host;
|
|
22
|
+
this.#doc = doc;
|
|
23
|
+
this.#selection = options.selectionLayout
|
|
24
|
+
? new Toolbar(host, doc, { layout: options.selectionLayout, label: 'Selection formatting' })
|
|
25
|
+
: null;
|
|
26
|
+
this.#insert = options.insertLayout
|
|
27
|
+
? new Toolbar(host, doc, { layout: options.insertLayout, label: 'Insert' })
|
|
28
|
+
: null;
|
|
29
|
+
if (this.#selection) {
|
|
30
|
+
this.#selection.el.classList.add('ol-floating');
|
|
31
|
+
this.#selection.el.hidden = true;
|
|
32
|
+
host.appendChild(this.#selection.el);
|
|
33
|
+
}
|
|
34
|
+
if (this.#insert) {
|
|
35
|
+
this.#insert.el.classList.add('ol-floating');
|
|
36
|
+
this.#insert.el.hidden = true;
|
|
37
|
+
host.appendChild(this.#insert.el);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
mount(view) {
|
|
41
|
+
this.#view = view;
|
|
42
|
+
this.#selection?.mount(view);
|
|
43
|
+
this.#insert?.mount(view);
|
|
44
|
+
}
|
|
45
|
+
update(state) {
|
|
46
|
+
this.#selection?.update(state);
|
|
47
|
+
this.#insert?.update(state);
|
|
48
|
+
this.#position(state);
|
|
49
|
+
}
|
|
50
|
+
destroy() {
|
|
51
|
+
this.#selection?.destroy();
|
|
52
|
+
this.#insert?.destroy();
|
|
53
|
+
this.#selection?.el.remove();
|
|
54
|
+
this.#insert?.el.remove();
|
|
55
|
+
}
|
|
56
|
+
#position(state) {
|
|
57
|
+
const view = this.#view;
|
|
58
|
+
if (!view)
|
|
59
|
+
return;
|
|
60
|
+
const empty = state.selection.empty;
|
|
61
|
+
if (this.#selection) {
|
|
62
|
+
this.#selection.el.hidden = empty;
|
|
63
|
+
if (!empty)
|
|
64
|
+
this.#place(this.#selection.el, view, state.selection.from);
|
|
65
|
+
}
|
|
66
|
+
if (this.#insert) {
|
|
67
|
+
const $from = state.selection.$from;
|
|
68
|
+
const showInsert = empty && $from.parent.isTextblock && $from.parent.content.size === 0;
|
|
69
|
+
this.#insert.el.hidden = !showInsert;
|
|
70
|
+
if (showInsert)
|
|
71
|
+
this.#place(this.#insert.el, view, state.selection.from);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
#place(el, view, pos) {
|
|
75
|
+
const coords = view.coordsAtPos(pos);
|
|
76
|
+
const hostBox = this.#host.getBoundingClientRect();
|
|
77
|
+
el.style.left = `${coords.left - hostBox.left}px`;
|
|
78
|
+
el.style.top = `${coords.bottom - hostBox.top + 8}px`;
|
|
79
|
+
void this.#doc;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=floating.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floating.js","sourceRoot":"","sources":["../src/floating.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,MAAM,CAAC,MAAM,wBAAwB,GAAG,8BAA8B,CAAA;AACtE,MAAM,CAAC,MAAM,qBAAqB,GAAG,2BAA2B,CAAA;AAEhE,MAAM,OAAO,gBAAgB;IAC3B,KAAK,CAAa;IAClB,IAAI,CAAU;IACd,KAAK,GAAsB,IAAI,CAAA;IAC/B,UAAU,CAAgB;IAC1B,OAAO,CAAgB;IAEvB,YACE,IAAiB,EACjB,GAAa,EACb,OAA0E;QAE1E,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAA;QACf,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,eAAe;YACvC,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,eAAe,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;YAC5F,CAAC,CAAC,IAAI,CAAA;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,YAAY;YACjC,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;YAC3E,CAAC,CAAC,IAAI,CAAA;QACR,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;YAC/C,I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|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-editor help: the shortcut table plus the chrome controls that have no
|
|
3
|
+
* key of their own.
|
|
4
|
+
*
|
|
5
|
+
* The shortcut list is the same array `buildKeymap` reads. A hand-maintained
|
|
6
|
+
* help page that drifted from the keymap would be worse than no help at all.
|
|
7
|
+
*/
|
|
8
|
+
export declare function promptHelp(doc: Document): void;
|
|
9
|
+
//# sourceMappingURL=help.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CA2D9C"}
|
package/dist/help.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-editor help: the shortcut table plus the chrome controls that have no
|
|
3
|
+
* key of their own.
|
|
4
|
+
*
|
|
5
|
+
* The shortcut list is the same array `buildKeymap` reads. A hand-maintained
|
|
6
|
+
* help page that drifted from the keymap would be worse than no help at all.
|
|
7
|
+
*/
|
|
8
|
+
import { shortcutFor, shortcuts } from '@openleaf-editor/core';
|
|
9
|
+
import { ensureDialogStyles } from './dialog.js';
|
|
10
|
+
import { t } from './i18n.js';
|
|
11
|
+
import { ensureStyles } from './styles.js';
|
|
12
|
+
const HELP_CHROME = [
|
|
13
|
+
['Alt+F10', 'Move focus to the formatting toolbar'],
|
|
14
|
+
['Escape', 'Return focus to the document'],
|
|
15
|
+
['F1', 'Open this help dialog'],
|
|
16
|
+
];
|
|
17
|
+
export function promptHelp(doc) {
|
|
18
|
+
ensureStyles(doc);
|
|
19
|
+
ensureDialogStyles(doc);
|
|
20
|
+
const previouslyFocused = doc.activeElement;
|
|
21
|
+
const dialog = doc.createElement('dialog');
|
|
22
|
+
dialog.className = 'ol-dialog ol-help';
|
|
23
|
+
dialog.setAttribute('aria-labelledby', 'ol-help-title');
|
|
24
|
+
const form = doc.createElement('form');
|
|
25
|
+
form.method = 'dialog';
|
|
26
|
+
const heading = doc.createElement('h2');
|
|
27
|
+
heading.id = 'ol-help-title';
|
|
28
|
+
heading.textContent = t('Keyboard shortcuts');
|
|
29
|
+
form.appendChild(heading);
|
|
30
|
+
const table = doc.createElement('table');
|
|
31
|
+
table.className = 'ol-help-table';
|
|
32
|
+
const body = doc.createElement('tbody');
|
|
33
|
+
for (const shortcut of shortcuts) {
|
|
34
|
+
const row = doc.createElement('tr');
|
|
35
|
+
const keys = doc.createElement('th');
|
|
36
|
+
keys.scope = 'row';
|
|
37
|
+
keys.textContent = shortcutFor(shortcut.label) ?? shortcut.keys;
|
|
38
|
+
const label = doc.createElement('td');
|
|
39
|
+
label.textContent = t(shortcut.label);
|
|
40
|
+
row.appendChild(keys);
|
|
41
|
+
row.appendChild(label);
|
|
42
|
+
body.appendChild(row);
|
|
43
|
+
}
|
|
44
|
+
for (const [keys, label] of HELP_CHROME) {
|
|
45
|
+
const row = doc.createElement('tr');
|
|
46
|
+
const keyCell = doc.createElement('th');
|
|
47
|
+
keyCell.scope = 'row';
|
|
48
|
+
keyCell.textContent = keys;
|
|
49
|
+
const labelCell = doc.createElement('td');
|
|
50
|
+
labelCell.textContent = t(label);
|
|
51
|
+
row.appendChild(keyCell);
|
|
52
|
+
row.appendChild(labelCell);
|
|
53
|
+
body.appendChild(row);
|
|
54
|
+
}
|
|
55
|
+
table.appendChild(body);
|
|
56
|
+
form.appendChild(table);
|
|
57
|
+
const actions = doc.createElement('div');
|
|
58
|
+
actions.className = 'ol-actions';
|
|
59
|
+
const close = doc.createElement('button');
|
|
60
|
+
close.type = 'submit';
|
|
61
|
+
close.value = 'ok';
|
|
62
|
+
close.textContent = t('Close');
|
|
63
|
+
actions.appendChild(close);
|
|
64
|
+
form.appendChild(actions);
|
|
65
|
+
dialog.appendChild(form);
|
|
66
|
+
doc.body.appendChild(dialog);
|
|
67
|
+
dialog.addEventListener('close', () => {
|
|
68
|
+
dialog.remove();
|
|
69
|
+
previouslyFocused?.focus();
|
|
70
|
+
});
|
|
71
|
+
dialog.showModal();
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=help.js.map
|
package/dist/help.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,MAAM,WAAW,GAA4B;IAC3C,CAAC,SAAS,EAAE,sCAAsC,CAAC;IACnD,CAAC,QAAQ,EAAE,8BAA8B,CAAC;IAC1C,CAAC,IAAI,EAAE,uBAAuB,CAAC;CAChC,CAAA;AAED,MAAM,UAAU,UAAU,CAAC,GAAa;IACtC,YAAY,CAAC,GAAG,CAAC,CAAA;IACjB,kBAAkB,CAAC,GAAG,CAAC,CAAA;IACvB,MAAM,iBAAiB,GAAG,GAAG,CAAC,aAAmC,CAAA;IACjE,MAAM,MAAM,GAAG,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC1C,MAAM,CAAC,SAAS,GAAG,mBAAmB,CAAA;IACtC,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAA;IAEvD,MAAM,IAAI,GAAG,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;IACtC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAA;IAEtB,MAAM,OAAO,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;IACvC,OAAO,CAAC,EAAE,GAAG,eAAe,CAAA;IAC5B,OAAO,CAAC,WAAW,GAAG,CAAC,CAAC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,CAAC,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,CAAA;QAChC,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QACxB,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;QAC1B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IACD,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IACvB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IAEvB,MAAM,OAAO,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IACxC,OAAO,CAAC,SAAS,GAAG,YAAY,CAAA;IAChC,MAAM,KAAK,GAAG,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IACzC,KAAK,CAAC,IAAI,GAAG,QAAQ,CAAA;IACrB,KAAK,CAAC,KAAK,GAAG,IAAI,CAAA;IAClB,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,OAAO,CAAC,CAAA;IAC9B,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IAC1B,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;IACzB,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IACxB,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IAC5B,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;QACpC,MAAM,CAAC,MAAM,EAAE,CAAA;QACf,iBAAiB,EAAE,KAAK,EAAE,CAAA;IAC5B,CAAC,CAAC,CAAA;IACF,MAAM,CAAC,SAAS,EAAE,CAAA;AACpB,CAAC"}
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI strings.
|
|
3
|
+
*
|
|
4
|
+
* English source text is the lookup key, so a missing translation still shows
|
|
5
|
+
* something an author can read, and a new button does not require a coordinated
|
|
6
|
+
* catalog bump before it can ship. `registerTranslations` overlays a locale;
|
|
7
|
+
* last registration for a key wins, which is how a host replaces one phrase
|
|
8
|
+
* without forking the catalog.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Run `render` with `forLocale` in force, then put the previous one back.
|
|
12
|
+
*
|
|
13
|
+
* Each editor carries its own `lang`, and the document-wide locale cannot serve
|
|
14
|
+
* that: two editors with different languages on one page would both end up in
|
|
15
|
+
* whichever built last. Threading a locale argument through every label in every
|
|
16
|
+
* component would say the same thing far more loudly, so the scope is a
|
|
17
|
+
* synchronous one instead -- labels produced while rendering see their own
|
|
18
|
+
* editor's locale.
|
|
19
|
+
*
|
|
20
|
+
* Synchronous is the constraint worth knowing: a label built later, outside any
|
|
21
|
+
* render, falls back to the document locale.
|
|
22
|
+
*/
|
|
23
|
+
export declare function withLocale<T>(forLocale: string | null | undefined, render: () => T): T;
|
|
24
|
+
export declare function onLocaleChange(listener: () => void): () => void;
|
|
25
|
+
/** The document-wide locale. Inside `withLocale` the scoped one wins. */
|
|
26
|
+
export declare function uiLocale(): string;
|
|
27
|
+
export declare function setUiLocale(next: string): void;
|
|
28
|
+
export declare function registerTranslations(forLocale: string, messages: Record<string, string>): void;
|
|
29
|
+
/** Translate a source string. Falls back to the string itself. */
|
|
30
|
+
export declare function t(source: string): string;
|
|
31
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAStF;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAK/D;AAYD,yEAAyE;AACzE,wBAAgB,QAAQ,IAAI,MAAM,CAEjC;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAK9C;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAQ9F;AAED,kEAAkE;AAClE,wBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAUxC"}
|
package/dist/i18n.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI strings.
|
|
3
|
+
*
|
|
4
|
+
* English source text is the lookup key, so a missing translation still shows
|
|
5
|
+
* something an author can read, and a new button does not require a coordinated
|
|
6
|
+
* catalog bump before it can ship. `registerTranslations` overlays a locale;
|
|
7
|
+
* last registration for a key wins, which is how a host replaces one phrase
|
|
8
|
+
* without forking the catalog.
|
|
9
|
+
*/
|
|
10
|
+
const catalogs = new Map();
|
|
11
|
+
const listeners = new Set();
|
|
12
|
+
let locale = 'en';
|
|
13
|
+
let scoped = null;
|
|
14
|
+
/**
|
|
15
|
+
* Run `render` with `forLocale` in force, then put the previous one back.
|
|
16
|
+
*
|
|
17
|
+
* Each editor carries its own `lang`, and the document-wide locale cannot serve
|
|
18
|
+
* that: two editors with different languages on one page would both end up in
|
|
19
|
+
* whichever built last. Threading a locale argument through every label in every
|
|
20
|
+
* component would say the same thing far more loudly, so the scope is a
|
|
21
|
+
* synchronous one instead -- labels produced while rendering see their own
|
|
22
|
+
* editor's locale.
|
|
23
|
+
*
|
|
24
|
+
* Synchronous is the constraint worth knowing: a label built later, outside any
|
|
25
|
+
* render, falls back to the document locale.
|
|
26
|
+
*/
|
|
27
|
+
export function withLocale(forLocale, render) {
|
|
28
|
+
if (!forLocale)
|
|
29
|
+
return render();
|
|
30
|
+
const previous = scoped;
|
|
31
|
+
scoped = forLocale;
|
|
32
|
+
try {
|
|
33
|
+
return render();
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
scoped = previous;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function onLocaleChange(listener) {
|
|
40
|
+
listeners.add(listener);
|
|
41
|
+
return () => {
|
|
42
|
+
listeners.delete(listener);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function notify() {
|
|
46
|
+
for (const listener of listeners) {
|
|
47
|
+
try {
|
|
48
|
+
listener();
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.error('@openleaf-editor/ui: a locale listener threw', error);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** The document-wide locale. Inside `withLocale` the scoped one wins. */
|
|
56
|
+
export function uiLocale() {
|
|
57
|
+
return scoped ?? locale;
|
|
58
|
+
}
|
|
59
|
+
export function setUiLocale(next) {
|
|
60
|
+
const value = next.trim() || 'en';
|
|
61
|
+
if (value === locale)
|
|
62
|
+
return;
|
|
63
|
+
locale = value;
|
|
64
|
+
notify();
|
|
65
|
+
}
|
|
66
|
+
export function registerTranslations(forLocale, messages) {
|
|
67
|
+
const existing = catalogs.get(forLocale) ?? {};
|
|
68
|
+
catalogs.set(forLocale, { ...existing, ...messages });
|
|
69
|
+
// Notified whatever locale this is for. Each editor now carries its own, so
|
|
70
|
+
// "does this match the document locale" no longer answers "does anybody care":
|
|
71
|
+
// a catalog registered after the editors were built -- the ordinary case for a
|
|
72
|
+
// script tag -- would otherwise never reach the editor it was meant for.
|
|
73
|
+
notify();
|
|
74
|
+
}
|
|
75
|
+
/** Translate a source string. Falls back to the string itself. */
|
|
76
|
+
export function t(source) {
|
|
77
|
+
const current = scoped ?? locale;
|
|
78
|
+
const exact = catalogs.get(current)?.[source];
|
|
79
|
+
if (exact)
|
|
80
|
+
return exact;
|
|
81
|
+
const language = current.split('-')[0];
|
|
82
|
+
if (language && language !== current) {
|
|
83
|
+
const regional = catalogs.get(language)?.[source];
|
|
84
|
+
if (regional)
|
|
85
|
+
return regional;
|
|
86
|
+
}
|
|
87
|
+
return catalogs.get('en')?.[source] ?? source;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=i18n.js.map
|
package/dist/i18n.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkC,CAAA;AAC1D,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;AACvC,IAAI,MAAM,GAAG,IAAI,CAAA;AACjB,IAAI,MAAM,GAAkB,IAAI,CAAA;AAEhC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,UAAU,CAAI,SAAoC,EAAE,MAAe;IACjF,IAAI,CAAC,SAAS;QAAE,OAAO,MAAM,EAAE,CAAA;IAC/B,MAAM,QAAQ,GAAG,MAAM,CAAA;IACvB,MAAM,GAAG,SAAS,CAAA;IAClB,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,CAAA;IACjB,CAAC;YAAS,CAAC;QACT,MAAM,GAAG,QAAQ,CAAA;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAoB;IACjD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACvB,OAAO,GAAG,EAAE;QACV,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC5B,CAAC,CAAA;AACH,CAAC;AAED,SAAS,MAAM;IACb,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC;YACH,QAAQ,EAAE,CAAA;QACZ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAA;QACtE,CAAC;IACH,CAAC;AACH,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,QAAQ;IACtB,OAAO,MAAM,I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 -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../src/icons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../src/icons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAoCH;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAA;AA2B7B,wBAAgB,SAAS,IAAI,QAAQ,EAAE,CAEtC;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,EAAE,QAAQ,GAAG,IAAI,CAgBjF;AAKD,oEAAoE;AACpE,wBAAgB,YAAY,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CAchD;AAiBD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,GAAG,aAAa,CAYxE"}
|
package/dist/icons.js
CHANGED
|
@@ -50,6 +50,10 @@ const PATHS = {
|
|
|
50
50
|
undo: 'M3 7v6h6M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13',
|
|
51
51
|
redo: 'M21 7v6h-6M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13',
|
|
52
52
|
source: 'M18 16l4-4-4-4M6 8l-4 4 4 4M14.5 4l-5 16',
|
|
53
|
+
more: 'M6 12h.01M12 12h.01M18 12h.01',
|
|
54
|
+
fullscreen: 'M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5',
|
|
55
|
+
help: 'M12 18h.01M9.1 9a3 3 0 1 1 5.8 1c0 2-3 2-3 4',
|
|
56
|
+
visualAids: 'M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12zM12 12a2 2 0 1 0 .01 0',
|
|
53
57
|
};
|
|
54
58
|
/**
|
|
55
59
|
* Icons whose meaning depends on reading direction, and which must therefore be
|
package/dist/icons.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../src/icons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;;GAMG;AACH,MAAM,KAAK,GAA2B;IACpC,IAAI,EAAE,iDAAiD;IACvD,MAAM,EAAE,4BAA4B;IACpC,SAAS,EAAE,iCAAiC;IAC5C,aAAa,EAAE,wDAAwD;IACvE,IAAI,EAAE,6BAA6B;IACnC,UAAU,EAAE,mDAAmD;IAC/D,WAAW,EAAE,6EAA6E;IAC1F,UAAU,EAAE,+BAA+B;IAC3C,SAAS,EAAE,2CAA2C;IACtD,IAAI,EAAE,yHAAyH;IAC/H,MAAM,EAAE,qHAAqH;IAC7H,KAAK,EAAE,2DAA2D;IAClE,cAAc,EAAE,UAAU;IAC1B,SAAS,EAAE,yBAAyB;IACpC,WAAW,EAAE,yBAAyB;IACtC,UAAU,EAAE,0BAA0B;IACtC,YAAY,EAAE,yBAAyB;IACvC,IAAI,EAAE,mDAAmD;IACzD,IAAI,EAAE,qDAAqD;IAC3D,MAAM,EAAE,0CAA0C;
|
|
1
|
+
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../src/icons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;;GAMG;AACH,MAAM,KAAK,GAA2B;IACpC,IAAI,EAAE,iDAAiD;IACvD,MAAM,EAAE,4BAA4B;IACpC,SAAS,EAAE,iCAAiC;IAC5C,aAAa,EAAE,wDAAwD;IACvE,IAAI,EAAE,6BAA6B;IACnC,UAAU,EAAE,mDAAmD;IAC/D,WAAW,EAAE,6EAA6E;IAC1F,UAAU,EAAE,+BAA+B;IAC3C,SAAS,EAAE,2CAA2C;IACtD,IAAI,EAAE,yHAAyH;IAC/H,MA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AAE,SAAS,IAAI,EAAE,CAAC,CAAA;IACzC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IACpB,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
export { Toolbar, type ToolbarOptions } from './toolbar.js';
|
|
2
2
|
export { DEFAULT_LAYOUT, LAYOUT_WITH_COLOUR, allToolbarItems, clearToolbarItems, getToolbarItem, onRegistryChange, registerToolbarItem, type ToolbarContext, type ToolbarControl, type ToolbarItemSpec, } from './registry.js';
|
|
3
|
-
export { SOURCE_TOGGLE_EVENT, registerDefaultItems } from './items.js';
|
|
3
|
+
export { SOURCE_TOGGLE_EVENT, FULLSCREEN_TOGGLE_EVENT, VISUAL_AIDS_TOGGLE_EVENT, registerDefaultItems } from './items.js';
|
|
4
|
+
export { t, setUiLocale, uiLocale, registerTranslations, onLocaleChange, withLocale, } from './i18n.js';
|
|
5
|
+
export { MenuBar, PopupMenu, DEFAULT_MENUBAR, selectMenus, LINK_CONTEXT_ITEMS, IMAGE_CONTEXT_ITEMS, TABLE_CONTEXT_ITEMS, type MenuSpec, type MenuEntry, } from './menu.js';
|
|
6
|
+
export { promptHelp } from './help.js';
|
|
7
|
+
export { FloatingToolbars, DEFAULT_SELECTION_LAYOUT, DEFAULT_INSERT_LAYOUT, } from './floating.js';
|
|
8
|
+
export { loadContentCss, contentCssUrls, scopeContentCss } from './content-css.js';
|
|
4
9
|
export { CSS, ensureStyles, markStylesExternal, registerStyles } from './styles.js';
|
|
5
10
|
export { ensureSprite, iconElement, iconNames, registerIcons, type IconName } from './icons.js';
|
|
6
|
-
export { promptForImage, promptForLink, type ImagePromptOptions, type ImageResult, type LinkResult, } from './dialog.js';
|
|
11
|
+
export { promptFields, promptForImage, promptForLink, type FieldOption, type FieldSpec, type ImagePromptOptions, type ImageResult, type LinkResult, type PromptFormOptions, } from './dialog.js';
|
|
12
|
+
export { filePickerFor, listedImageClasses, listedImages, listedLinks, registerFilePicker, registerImageClasses, registerImageList, registerLinkList, type FilePicker, type FilePickerKind, type ListedResource, type PickedResource, } from './pickers.js';
|
|
7
13
|
export { IMAGE_ACCEPT, canUploadImages, imageFilesFrom, imageUploaderFor, isUploadableImage, registerImageUploader, runUploader, type ImageUploadResult, type ImageUploader, } from './upload.js';
|
|
8
14
|
export { BUILT_IN_SKINS, applyColourScheme, applySkin, availableSkins, ensureSkins, registerSkin, type ColourScheme, type Skin, } from './skins.js';
|
|
9
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACzH,OAAO,EACL,CAAC,EACD,WAAW,EACX,QA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W,EACX,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,IAAI,GACV,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
export { Toolbar } from './toolbar.js';
|
|
2
2
|
export { DEFAULT_LAYOUT, LAYOUT_WITH_COLOUR, allToolbarItems, clearToolbarItems, getToolbarItem, onRegistryChange, registerToolbarItem, } from './registry.js';
|
|
3
|
-
export { SOURCE_TOGGLE_EVENT, registerDefaultItems } from './items.js';
|
|
3
|
+
export { SOURCE_TOGGLE_EVENT, FULLSCREEN_TOGGLE_EVENT, VISUAL_AIDS_TOGGLE_EVENT, registerDefaultItems } from './items.js';
|
|
4
|
+
export { t, setUiLocale, uiLocale, registerTranslations, onLocaleChange, withLocale, } from './i18n.js';
|
|
5
|
+
export { MenuBar, PopupMenu, DEFAULT_MENUBAR, selectMenus, LINK_CONTEXT_ITEMS, IMAGE_CONTEXT_ITEMS, TABLE_CONTEXT_ITEMS, } from './menu.js';
|
|
6
|
+
export { promptHelp } from './help.js';
|
|
7
|
+
export { FloatingToolbars, DEFAULT_SELECTION_LAYOUT, DEFAULT_INSERT_LAYOUT, } from './floating.js';
|
|
8
|
+
export { loadContentCss, contentCssUrls, scopeContentCss } from './content-css.js';
|
|
4
9
|
export { CSS, ensureStyles, markStylesExternal, registerStyles } from './styles.js';
|
|
5
10
|
export { ensureSprite, iconElement, iconNames, registerIcons } from './icons.js';
|
|
6
|
-
export { promptForImage, promptForLink, } from './dialog.js';
|
|
11
|
+
export { promptFields, promptForImage, promptForLink, } from './dialog.js';
|
|
12
|
+
export { filePickerFor, listedImageClasses, listedImages, listedLinks, registerFilePicker, registerImageClasses, registerImageList, registerLinkList, } from './pickers.js';
|
|
7
13
|
export { IMAGE_ACCEPT, canUploadImages, imageFilesFrom, imageUploaderFor, isUploadableImage, registerImageUploader, runUploader, } from './upload.js';
|
|
8
14
|
export { BUILT_IN_SKINS, applyColourScheme, applySkin, availableSkins, ensureSkins, registerSkin, } from './skins.js';
|
|
9
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,cAAc,CAAA;AAC3D,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,GAIpB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,cAAc,CAAA;AAC3D,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,GAIpB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACzH,OAAO,EACL,CAAC,EACD,WAAW,EACX,QAAQ,EACR,oBAAoB,EACpB,cAAc,EACd,UAAU,GACX,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,OAAO,EACP,SAAS,EACT,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,GAGpB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClF,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACnF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAA;AAC/F,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,GAOd,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,GAKjB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,WAAW,GAGZ,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,WAAW,EACX,YAAY,GAGb,MAAM,YAAY,CAAA"}
|
package/dist/items.d.ts
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
/** Event the host listens for to switch between rich and source views. */
|
|
10
10
|
export declare const SOURCE_TOGGLE_EVENT = "openleaf:toggle-source";
|
|
11
|
+
export declare const FULLSCREEN_TOGGLE_EVENT = "openleaf:toggle-fullscreen";
|
|
12
|
+
export declare const VISUAL_AIDS_TOGGLE_EVENT = "openleaf:toggle-visual-aids";
|
|
11
13
|
/** Register the built-in items. Idempotent. */
|
|
12
14
|
export declare function registerDefaultItems(): void;
|
|
13
15
|
//# sourceMappingURL=items.d.ts.map
|
package/dist/items.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../src/items.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../src/items.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgCH,0EAA0E;AAC1E,eAAO,MAAM,mBAAmB,2BAA2B,CAAA;AAC3D,eAAO,MAAM,uBAAuB,+BAA+B,CAAA;AACnE,eAAO,MAAM,wBAAwB,gCAAgC,CAAA;AAIrE,+CAA+C;AAC/C,wBAAgB,oBAAoB,IAAI,IAAI,CAuR3C"}
|
package/dist/items.js
CHANGED
|
@@ -8,10 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { activeLink, activeTextAlign, insertHorizontalRule, insertImage, isMarkActive, isNodeActive, redo, setLink, toggleBlockquote, toggleBold, toggleBulletList, toggleCodeBlock, toggleInlineCode, toggleItalic, toggleOrderedList, toggleStrike, toggleTextAlign, toggleUnderline, undo, unsetLink, } from '@openleaf-editor/core';
|
|
10
10
|
import { promptForImage, promptForLink } from './dialog.js';
|
|
11
|
+
import { promptHelp } from './help.js';
|
|
11
12
|
import { registerToolbarItem } from './registry.js';
|
|
12
13
|
import { imageUploaderFor, runUploader } from './upload.js';
|
|
13
14
|
/** Event the host listens for to switch between rich and source views. */
|
|
14
15
|
export const SOURCE_TOGGLE_EVENT = 'openleaf:toggle-source';
|
|
16
|
+
export const FULLSCREEN_TOGGLE_EVENT = 'openleaf:toggle-fullscreen';
|
|
17
|
+
export const VISUAL_AIDS_TOGGLE_EVENT = 'openleaf:toggle-visual-aids';
|
|
15
18
|
let registered = false;
|
|
16
19
|
/** Register the built-in items. Idempotent. */
|
|
17
20
|
export function registerDefaultItems() {
|
|
@@ -151,8 +154,9 @@ export function registerDefaultItems() {
|
|
|
151
154
|
const existing = activeLink(view.state);
|
|
152
155
|
void promptForLink(host.ownerDocument, {
|
|
153
156
|
href: existing?.['href'] ?? '',
|
|
157
|
+
title: existing?.['title'] ?? null,
|
|
154
158
|
target: existing?.['target'] ?? null,
|
|
155
|
-
}).then((result) => {
|
|
159
|
+
}, host).then((result) => {
|
|
156
160
|
if (!result) {
|
|
157
161
|
view.focus();
|
|
158
162
|
return;
|
|
@@ -182,8 +186,8 @@ export function registerDefaultItems() {
|
|
|
182
186
|
// worse than no picker: the author has already chosen the file.
|
|
183
187
|
const uploader = imageUploaderFor(host);
|
|
184
188
|
const options = uploader
|
|
185
|
-
? { upload: (file) => runUploader(uploader, file, host) }
|
|
186
|
-
: {};
|
|
189
|
+
? { upload: (file) => runUploader(uploader, file, host), host }
|
|
190
|
+
: { host };
|
|
187
191
|
void promptForImage(host.ownerDocument, options).then((result) => {
|
|
188
192
|
if (!result) {
|
|
189
193
|
view.focus();
|
|
@@ -192,8 +196,12 @@ export function registerDefaultItems() {
|
|
|
192
196
|
insertImage({
|
|
193
197
|
src: result.src,
|
|
194
198
|
alt: result.alt,
|
|
199
|
+
title: result.title,
|
|
195
200
|
width: result.width,
|
|
196
201
|
height: result.height,
|
|
202
|
+
align: result.align,
|
|
203
|
+
className: result.className,
|
|
204
|
+
...(result.caption ? { caption: result.caption } : {}),
|
|
197
205
|
})(view.state, view.dispatch, view);
|
|
198
206
|
view.focus();
|
|
199
207
|
});
|
|
@@ -223,5 +231,37 @@ export function registerDefaultItems() {
|
|
|
223
231
|
host.dispatchEvent(new CustomEvent(SOURCE_TOGGLE_EVENT, { bubbles: true }));
|
|
224
232
|
},
|
|
225
233
|
});
|
|
234
|
+
registerToolbarItem({
|
|
235
|
+
id: 'fullscreen',
|
|
236
|
+
type: 'button',
|
|
237
|
+
kind: 'toggle',
|
|
238
|
+
label: 'Fullscreen',
|
|
239
|
+
icon: 'fullscreen',
|
|
240
|
+
isActive: () => false,
|
|
241
|
+
run: ({ host }) => {
|
|
242
|
+
host.dispatchEvent(new CustomEvent(FULLSCREEN_TOGGLE_EVENT, { bubbles: true }));
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
registerToolbarItem({
|
|
246
|
+
id: 'visualAids',
|
|
247
|
+
type: 'button',
|
|
248
|
+
kind: 'toggle',
|
|
249
|
+
label: 'Visual aids',
|
|
250
|
+
icon: 'visualAids',
|
|
251
|
+
isActive: () => false,
|
|
252
|
+
run: ({ host }) => {
|
|
253
|
+
host.dispatchEvent(new CustomEvent(VISUAL_AIDS_TOGGLE_EVENT, { bubbles: true }));
|
|
254
|
+
},
|
|
255
|
+
});
|
|
256
|
+
registerToolbarItem({
|
|
257
|
+
id: 'help',
|
|
258
|
+
type: 'button',
|
|
259
|
+
kind: 'action',
|
|
260
|
+
label: 'Help',
|
|
261
|
+
icon: 'help',
|
|
262
|
+
run: ({ host }) => {
|
|
263
|
+
promptHelp(host.ownerDocument);
|
|
264
|
+
},
|
|
265
|
+
});
|
|
226
266
|
}
|
|
227
267
|
//# sourceMappingURL=items.js.map
|
package/dist/items.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"items.js","sourceRoot":"","sources":["../src/items.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,IAAI,EACJ,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,IAAI,EACJ,SAAS,GAEV,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"items.js","sourceRoot":"","sources":["../src/items.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,IAAI,EACJ,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,IAAI,EACJ,SAAS,GAEV,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3D,OA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AmB,CAAC;QAClB,EAAE,EAAE,YAAY;QAChB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK;QACrB,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;YAChB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,uBAAuB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QACjF,CAAC;KACF,CAAC,CAAA;IAEF,mBAAmB,CAAC;QAClB,EAAE,EAAE,YAAY;QAChB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,aAAa;QACpB,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK;QACrB,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;YAChB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,wBAAwB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QAClF,CAAC;KACF,CAAC,CAAA;IAEF,mBAAmB,CAAC;QAClB,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,MAAM;QACb,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;YAChB,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;QAChC,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
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
|