@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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load content CSS so the canvas matches the published site.
|
|
3
|
+
*
|
|
4
|
+
* OpenLeaf has no iframe. Host typography already inherits into the document,
|
|
5
|
+
* which is the point of skipping Shadow DOM. This helper is for an extra
|
|
6
|
+
* stylesheet the published template uses -- a CMS "styles.css" -- that is not
|
|
7
|
+
* on the admin page. Selectors are scoped under the editor canvas so a rule
|
|
8
|
+
* written for `p.lead` cannot restyle the rest of the admin chrome.
|
|
9
|
+
*/
|
|
10
|
+
export declare function scopeContentCss(css: string): string;
|
|
11
|
+
export declare function loadContentCss(doc: Document, urls: readonly string[]): Promise<void>;
|
|
12
|
+
export declare function contentCssUrls(value: string | null): string[];
|
|
13
|
+
//# sourceMappingURL=content-css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-css.d.ts","sourceRoot":"","sources":["../src/content-css.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAcnD;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB1F;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,EAAE,CAM7D"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load content CSS so the canvas matches the published site.
|
|
3
|
+
*
|
|
4
|
+
* OpenLeaf has no iframe. Host typography already inherits into the document,
|
|
5
|
+
* which is the point of skipping Shadow DOM. This helper is for an extra
|
|
6
|
+
* stylesheet the published template uses -- a CMS "styles.css" -- that is not
|
|
7
|
+
* on the admin page. Selectors are scoped under the editor canvas so a rule
|
|
8
|
+
* written for `p.lead` cannot restyle the rest of the admin chrome.
|
|
9
|
+
*/
|
|
10
|
+
export function scopeContentCss(css) {
|
|
11
|
+
return css.replace(/(^|})(\s*)([^@{}][^{]*)\{/g, (full, brace, space, selector) => {
|
|
12
|
+
if (selector.trim().startsWith('@'))
|
|
13
|
+
return full;
|
|
14
|
+
const scoped = selector
|
|
15
|
+
.split(',')
|
|
16
|
+
.map((part) => {
|
|
17
|
+
const trimmed = part.trim();
|
|
18
|
+
if (!trimmed)
|
|
19
|
+
return part;
|
|
20
|
+
if (trimmed.startsWith('.ol-editor') || trimmed.startsWith('.ol-content'))
|
|
21
|
+
return trimmed;
|
|
22
|
+
return `.ol-editor .ol-content .ProseMirror ${trimmed}`;
|
|
23
|
+
})
|
|
24
|
+
.join(', ');
|
|
25
|
+
return `${brace}${space}${scoped}{`;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export async function loadContentCss(doc, urls) {
|
|
29
|
+
if (typeof CSSStyleSheet === 'undefined' || !('adoptedStyleSheets' in Document.prototype)) {
|
|
30
|
+
console.warn('@openleaf-editor/ui: content CSS could not be adopted in this browser. ' +
|
|
31
|
+
'Link the published stylesheet on the host page instead.');
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
for (const url of urls) {
|
|
35
|
+
try {
|
|
36
|
+
const response = await fetch(url);
|
|
37
|
+
if (!response.ok)
|
|
38
|
+
throw new Error(`HTTP ${response.status}`);
|
|
39
|
+
const css = scopeContentCss(await response.text());
|
|
40
|
+
const sheet = new CSSStyleSheet();
|
|
41
|
+
sheet.replaceSync(css);
|
|
42
|
+
doc.adoptedStyleSheets = [...doc.adoptedStyleSheets, sheet];
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.warn(`@openleaf-editor/ui: content CSS at "${url}" could not be loaded.`, error);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function contentCssUrls(value) {
|
|
50
|
+
if (!value)
|
|
51
|
+
return [];
|
|
52
|
+
return value
|
|
53
|
+
.split(/[, ]+/)
|
|
54
|
+
.map((part) => part.trim())
|
|
55
|
+
.filter(Boolean);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=content-css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-css.js","sourceRoot":"","sources":["../src/content-css.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,GAAG,CAAC,OAAO,CAAC,4BAA4B,EAAE,CAAC,IAAI,EAAE,KAAa,EAAE,KAAa,EAAE,QAAgB,EAAE,EAAE;QACxG,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAA;QAChD,MAAM,MAAM,GAAG,QAAQ;aACpB,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YACZ,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;YAC3B,IAAI,CAAC,OAAO;gBAAE,OAAO,IAAI,CAAA;YACzB,IAAI,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC;gBAAE,OAAO,OAAO,CAAA;YACzF,OAAO,uCAAuC,OAAO,EAAE,CAAA;QACzD,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAA;QACb,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CA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
* is a few hundred lines that would then owe real screen reader testing to be
|
|
7
7
|
* worth anything, and the native element is already tested by the browser
|
|
8
8
|
* vendors. Choosing it is the single biggest accessibility win available here.
|
|
9
|
+
*
|
|
10
|
+
* ## Why committing is asynchronous
|
|
11
|
+
*
|
|
12
|
+
* The image dialog uploads a file, and an upload is the one thing in this editor
|
|
13
|
+
* that can take five seconds and fail for a reason the author needs to read. So
|
|
14
|
+
* the form's commit step returns a promise: the dialog stays open while it runs,
|
|
15
|
+
* disables its buttons, says what it is doing in a polite live region, and on
|
|
16
|
+
* failure shows the message and keeps everything the author typed.
|
|
17
|
+
*
|
|
18
|
+
* The alternative -- close the dialog, upload in the background, report through a
|
|
19
|
+
* toast -- loses the alt text they wrote when the upload fails, and makes the
|
|
20
|
+
* retry a whole new dialog.
|
|
9
21
|
*/
|
|
22
|
+
import { type ImageUploadResult } from './upload.js';
|
|
10
23
|
export interface LinkResult {
|
|
11
24
|
href: string;
|
|
25
|
+
title: string | null;
|
|
12
26
|
target: string | null;
|
|
13
27
|
rel: string | null;
|
|
14
28
|
}
|
|
@@ -16,10 +30,81 @@ export interface ImageResult {
|
|
|
16
30
|
src: string;
|
|
17
31
|
/** `''` means explicitly decorative. `null` is never returned. */
|
|
18
32
|
alt: string;
|
|
33
|
+
title: string | null;
|
|
34
|
+
/** Intrinsic size, when an uploader reported one. */
|
|
35
|
+
width: string | null;
|
|
36
|
+
height: string | null;
|
|
37
|
+
className: string | null;
|
|
38
|
+
align: 'left' | 'right' | 'center' | null;
|
|
39
|
+
caption: string | null;
|
|
40
|
+
}
|
|
41
|
+
export interface FieldOption {
|
|
42
|
+
value: string;
|
|
43
|
+
label: string;
|
|
44
|
+
}
|
|
45
|
+
export interface FieldSpec {
|
|
46
|
+
name: string;
|
|
47
|
+
label: string;
|
|
48
|
+
type?: string;
|
|
49
|
+
value?: string;
|
|
50
|
+
required?: boolean;
|
|
51
|
+
hint?: string;
|
|
52
|
+
/** For `type: 'file'`: the accept list. */
|
|
53
|
+
accept?: string;
|
|
54
|
+
/** When set, the field is a `<select>` rather than an input. */
|
|
55
|
+
options?: readonly FieldOption[];
|
|
56
|
+
/**
|
|
57
|
+
* The field this control writes into when it changes.
|
|
58
|
+
*
|
|
59
|
+
* A chooser that only *contributed* its value could never change a field that
|
|
60
|
+
* was already filled in: editing a link or an image prefills the address, so
|
|
61
|
+
* picking from the list lost to it every time and the list worked only for new
|
|
62
|
+
* insertions. Writing into the field it fills keeps one source of truth, and
|
|
63
|
+
* shows the author what they picked so they can still edit it.
|
|
64
|
+
*/
|
|
65
|
+
fills?: string;
|
|
19
66
|
}
|
|
67
|
+
export declare function ensureDialogStyles(doc: Document): void;
|
|
68
|
+
export interface PromptFormOptions {
|
|
69
|
+
extraCheckbox?: {
|
|
70
|
+
name: string;
|
|
71
|
+
label: string;
|
|
72
|
+
hint?: string;
|
|
73
|
+
checked?: boolean;
|
|
74
|
+
};
|
|
75
|
+
note?: string;
|
|
76
|
+
busyLabel?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A generic modal form, used by table property dialogs and anything else that
|
|
80
|
+
* is a handful of labelled fields rather than a specialised prompt.
|
|
81
|
+
*/
|
|
82
|
+
export declare function promptFields<T>(doc: Document, title: string, fields: FieldSpec[], options: PromptFormOptions, commit: (values: Record<string, string>, files: Record<string, File | undefined>) => Promise<{
|
|
83
|
+
value: T;
|
|
84
|
+
} | {
|
|
85
|
+
error: string;
|
|
86
|
+
}> | {
|
|
87
|
+
value: T;
|
|
88
|
+
} | {
|
|
89
|
+
error: string;
|
|
90
|
+
}): Promise<T | null>;
|
|
20
91
|
export declare function promptForLink(doc: Document, existing?: {
|
|
21
92
|
href?: string;
|
|
93
|
+
title?: string | null;
|
|
22
94
|
target?: string | null;
|
|
23
|
-
}): Promise<LinkResult | null>;
|
|
24
|
-
export
|
|
95
|
+
}, host?: HTMLElement): Promise<LinkResult | null>;
|
|
96
|
+
export interface ImagePromptOptions {
|
|
97
|
+
file?: File;
|
|
98
|
+
upload?: (file: File) => Promise<ImageUploadResult>;
|
|
99
|
+
host?: HTMLElement;
|
|
100
|
+
existing?: {
|
|
101
|
+
src?: string;
|
|
102
|
+
alt?: string | null;
|
|
103
|
+
title?: string | null;
|
|
104
|
+
className?: string | null;
|
|
105
|
+
align?: 'left' | 'right' | 'center' | null;
|
|
106
|
+
caption?: string | null;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export declare function promptForImage(doc: Document, options?: ImagePromptOptions): Promise<ImageResult | null>;
|
|
25
110
|
//# sourceMappingURL=dialog.d.ts.map
|
package/dist/dialog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAQ7E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,qDAAqD;IACrD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,IAAI,CAAA;IACzC,OAAO,EAAE,MAAM,GAAG,IAAI,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