@openleaf-editor/ui 0.1.0-beta.0 → 0.1.0-beta.1
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/dialog.d.ts +39 -1
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +206 -63
- package/dist/dialog.js.map +1 -1
- package/dist/icons.d.ts +1 -1
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +13 -1
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/items.d.ts.map +1 -1
- package/dist/items.js +40 -3
- package/dist/items.js.map +1 -1
- 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/toolbar.d.ts.map +1 -1
- package/dist/toolbar.js +76 -4
- 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/items.js
CHANGED
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* document, that knowledge belongs in `@openleaf-editor/core` where a keyboard
|
|
7
7
|
* shortcut and a test can reach it too.
|
|
8
8
|
*/
|
|
9
|
-
import { activeLink, insertHorizontalRule, insertImage, isMarkActive, isNodeActive, redo, setLink, toggleBlockquote, toggleBold, toggleBulletList, toggleCodeBlock, toggleInlineCode, toggleItalic, toggleOrderedList, toggleStrike, toggleUnderline, undo, unsetLink, } from '@openleaf-editor/core';
|
|
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
11
|
import { registerToolbarItem } from './registry.js';
|
|
12
|
+
import { imageUploaderFor, runUploader } from './upload.js';
|
|
12
13
|
/** Event the host listens for to switch between rich and source views. */
|
|
13
14
|
export const SOURCE_TOGGLE_EVENT = 'openleaf:toggle-source';
|
|
14
15
|
let registered = false;
|
|
@@ -111,6 +112,30 @@ export function registerDefaultItems() {
|
|
|
111
112
|
isActive: (state) => isNodeActive(state, 'code_block'),
|
|
112
113
|
shortcut: 'Code block',
|
|
113
114
|
});
|
|
115
|
+
/* ---- alignment ----
|
|
116
|
+
Toggles, not actions, and the pressed state is the EXPLICIT alignment only.
|
|
117
|
+
A paragraph nobody has aligned follows the document's reading direction, so
|
|
118
|
+
lighting up the left button for it would be wrong in Arabic and Hebrew --
|
|
119
|
+
and `aria-pressed="true"` on a paragraph that is not left-aligned is a lie
|
|
120
|
+
a screen reader repeats. See activeTextAlign in core. */
|
|
121
|
+
const alignItems = [
|
|
122
|
+
{ id: 'alignLeft', label: 'Align left', icon: 'alignLeft', align: 'left' },
|
|
123
|
+
{ id: 'alignCenter', label: 'Align centre', icon: 'alignCenter', align: 'center' },
|
|
124
|
+
{ id: 'alignRight', label: 'Align right', icon: 'alignRight', align: 'right' },
|
|
125
|
+
{ id: 'alignJustify', label: 'Justify', icon: 'alignJustify', align: 'justify' },
|
|
126
|
+
];
|
|
127
|
+
for (const item of alignItems) {
|
|
128
|
+
registerToolbarItem({
|
|
129
|
+
id: item.id,
|
|
130
|
+
type: 'button',
|
|
131
|
+
kind: 'toggle',
|
|
132
|
+
label: item.label,
|
|
133
|
+
icon: item.icon,
|
|
134
|
+
command: toggleTextAlign(item.align),
|
|
135
|
+
isActive: (state) => activeTextAlign(state) === item.align,
|
|
136
|
+
shortcut: item.label,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
114
139
|
/* ---- insertions ---- */
|
|
115
140
|
registerToolbarItem({
|
|
116
141
|
id: 'link',
|
|
@@ -152,12 +177,24 @@ export function registerDefaultItems() {
|
|
|
152
177
|
label: 'Insert image',
|
|
153
178
|
icon: 'image',
|
|
154
179
|
run: ({ view, host }) => {
|
|
155
|
-
|
|
180
|
+
// One item, two dialogs, decided by whether this page can upload. A file
|
|
181
|
+
// picker that appears and then fails because no uploader was registered is
|
|
182
|
+
// worse than no picker: the author has already chosen the file.
|
|
183
|
+
const uploader = imageUploaderFor(host);
|
|
184
|
+
const options = uploader
|
|
185
|
+
? { upload: (file) => runUploader(uploader, file, host) }
|
|
186
|
+
: {};
|
|
187
|
+
void promptForImage(host.ownerDocument, options).then((result) => {
|
|
156
188
|
if (!result) {
|
|
157
189
|
view.focus();
|
|
158
190
|
return;
|
|
159
191
|
}
|
|
160
|
-
insertImage({
|
|
192
|
+
insertImage({
|
|
193
|
+
src: result.src,
|
|
194
|
+
alt: result.alt,
|
|
195
|
+
width: result.width,
|
|
196
|
+
height: result.height,
|
|
197
|
+
})(view.state, view.dispatch, view);
|
|
161
198
|
view.focus();
|
|
162
199
|
});
|
|
163
200
|
},
|
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,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,IAAI,EACJ,SAAS,
|
|
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,gBA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CAAC,GAAG;oBACf,GAAG,EAAE,MAAM,CAAC,GAAG;oBACf,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,MAAM,EAAE,MAAM,CAAC,MAAM;iBACtB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;gBACnC,IAAI,CAAC,KAAK,EAAE,CAAA;YACd,CAAC,CAAC,CAAA;QACJ,CAAC;KACF,CAAC,CAAA;IAEF,mBAAmB,CAAC;QAClB,EAAE,EAAE,gBAAgB;QACpB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,iBAAiB;QACxB,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,oBAAoB;QAC7B,QAAQ,EAAE,iBAAiB;KAC5B,CAAC,CAAA;IAEF,oBAAoB;IAEpB,mBAAmB,CAAC;QAClB,EAAE,EAAE,QAAQ;QACZ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,aAAa;QACpB,IAAI,EAAE,QAAQ;QACd,4EAA4E;QAC5E,0EAA0E;QAC1E,4BAA4B;QAC5B,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK;QACrB,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;YAChB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,mBAAmB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QAC7E,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/registry.d.ts
CHANGED
|
@@ -25,21 +25,44 @@ export interface ToolbarContext {
|
|
|
25
25
|
/** The `<openleaf-editor>` element, for dispatching events or hosting dialogs. */
|
|
26
26
|
host: HTMLElement;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* A control a `custom` item builds for itself.
|
|
30
|
+
*
|
|
31
|
+
* The contract is narrow on purpose. A custom item owns its own markup, so it
|
|
32
|
+
* can be a colour grid or a table-size picker, but it does not get to own the
|
|
33
|
+
* toolbar's keyboard model: the element it returns must contain exactly one
|
|
34
|
+
* focusable `button.ol-btn`, because that is what the roving tabindex walks. A
|
|
35
|
+
* control with two focusable buttons in the bar would make the toolbar two tab
|
|
36
|
+
* stops where the author expects one; a control with none would be unreachable
|
|
37
|
+
* by keyboard. Anything else the control needs -- a popover, a grid of swatches
|
|
38
|
+
* -- belongs outside the toolbar element, in the top layer or on the host.
|
|
39
|
+
*/
|
|
40
|
+
export interface ToolbarControl {
|
|
41
|
+
/** The element placed in the toolbar. */
|
|
42
|
+
el: HTMLElement;
|
|
43
|
+
/**
|
|
44
|
+
* Reflect the editor state. Called on every transaction, so it must be cheap
|
|
45
|
+
* and must not throw; a throw is caught and logged once, like a predicate.
|
|
46
|
+
*/
|
|
47
|
+
update?: (state: EditorState) => void;
|
|
48
|
+
/** Release listeners, and remove anything the control put in the document. */
|
|
49
|
+
destroy?: () => void;
|
|
50
|
+
}
|
|
28
51
|
export interface ToolbarItemSpec {
|
|
29
52
|
/** Stable id used in the `toolbar` layout attribute. */
|
|
30
53
|
id: string;
|
|
31
54
|
/**
|
|
32
55
|
* What kind of control this is.
|
|
33
56
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* `custom`.
|
|
57
|
+
* `button` is the common case. `custom` hands the item a chance to build its
|
|
58
|
+
* own DOM through `render`, which is how the colour picker exists at all: a
|
|
59
|
+
* swatch grid is not a button, and modelling it as one would have meant
|
|
60
|
+
* special-casing it in the toolbar by id, the way the block-type `select`
|
|
61
|
+
* still is.
|
|
40
62
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
63
|
+
* `select` remains unimplemented, and the block-type control is special-cased
|
|
64
|
+
* by id rather than being one. Declaring it logs a warning rather than
|
|
65
|
+
* rendering a plausible-looking button that is not the control asked for.
|
|
43
66
|
*/
|
|
44
67
|
type?: 'button' | 'select' | 'custom';
|
|
45
68
|
/** Accessible name. Kept constant across states -- the platform announces pressed. */
|
|
@@ -54,6 +77,11 @@ export interface ToolbarItemSpec {
|
|
|
54
77
|
command?: Command;
|
|
55
78
|
/** For items needing more than the editor state -- dialogs, mode switches. */
|
|
56
79
|
run?: (ctx: ToolbarContext) => void;
|
|
80
|
+
/**
|
|
81
|
+
* For `type: 'custom'`: build the control. Required for that type, ignored
|
|
82
|
+
* otherwise.
|
|
83
|
+
*/
|
|
84
|
+
render?: (ctx: ToolbarContext) => ToolbarControl;
|
|
57
85
|
isActive?: (state: EditorState) => boolean;
|
|
58
86
|
/** Defaults to asking `command` whether it would apply. */
|
|
59
87
|
isEnabled?: (state: EditorState) => boolean;
|
|
@@ -82,4 +110,17 @@ export declare function clearToolbarItems(): void;
|
|
|
82
110
|
* so it is not hit by accident.
|
|
83
111
|
*/
|
|
84
112
|
export declare const DEFAULT_LAYOUT: string;
|
|
113
|
+
/**
|
|
114
|
+
* The default layout with the colour controls in it.
|
|
115
|
+
*
|
|
116
|
+
* Not the default, and deliberately not: the colour picker ships in an opt-in
|
|
117
|
+
* bundle, and naming an item that is not registered logs a warning for every
|
|
118
|
+
* deployment that did not load it. An integrator who loads the colour bundle
|
|
119
|
+
* either uses this layout or names `textColour` and `highlightColour` in their own.
|
|
120
|
+
*
|
|
121
|
+
* The colour bundle does NOT rewrite the default layout on install. Installing a
|
|
122
|
+
* plugin must not silently rearrange somebody's toolbar -- that is the whole
|
|
123
|
+
* reason capability and layout are separate concerns here.
|
|
124
|
+
*/
|
|
125
|
+
export declare const LAYOUT_WITH_COLOUR: string;
|
|
85
126
|
//# sourceMappingURL=registry.d.ts.map
|
package/dist/registry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,OAA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,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAA;IAC1C,2DAA2D;IAC3D,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAA;IAC3C,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAcD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAGjE;AAcD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAG/D;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAEtE;AAED,wBAAgB,eAAe,IAAI,eAAe,EAAE,CAEnD;AAED,gDAAgD;AAChD,wBAAgB,iBAAiB,IAAI,IAAI,CAGxC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,QAGgE,CAAA;AAE3F;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,QAG9B,CAAA"}
|
package/dist/registry.js
CHANGED
|
@@ -73,5 +73,19 @@ export function clearToolbarItems() {
|
|
|
73
73
|
* so it is not hit by accident.
|
|
74
74
|
*/
|
|
75
75
|
export const DEFAULT_LAYOUT = 'undo redo | blockType | bold italic underline strikethrough code | ' +
|
|
76
|
+
'alignLeft alignCenter alignRight alignJustify | ' +
|
|
76
77
|
'bulletList orderedList blockquote codeBlock | link unlink image horizontalRule | source';
|
|
78
|
+
/**
|
|
79
|
+
* The default layout with the colour controls in it.
|
|
80
|
+
*
|
|
81
|
+
* Not the default, and deliberately not: the colour picker ships in an opt-in
|
|
82
|
+
* bundle, and naming an item that is not registered logs a warning for every
|
|
83
|
+
* deployment that did not load it. An integrator who loads the colour bundle
|
|
84
|
+
* either uses this layout or names `textColour` and `highlightColour` in their own.
|
|
85
|
+
*
|
|
86
|
+
* The colour bundle does NOT rewrite the default layout on install. Installing a
|
|
87
|
+
* plugin must not silently rearrange somebody's toolbar -- that is the whole
|
|
88
|
+
* reason capability and layout are separate concerns here.
|
|
89
|
+
*/
|
|
90
|
+
export const LAYOUT_WITH_COLOUR = DEFAULT_LAYOUT.replace('alignLeft', 'textColour highlightColour | alignLeft');
|
|
77
91
|
//# sourceMappingURL=registry.js.map
|
package/dist/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA8EH,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAA;AAEnD;;;;;;;GAOG;AACH,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;AAEvC,MAAM,UAAU,gBAAgB,CAAC,QAAoB;IACnD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACvB,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACzC,CAAC;AAED,SAAS,MAAM;IACb,4EAA4E;IAC5E,2EAA2E;IAC3E,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,oDAAoD,EAAE,KAAK,CAAC,CAAA;QAC5E,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAqB;IACvD,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;IAC3B,MAAM,EAAE,CAAA;AACV,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAAU;IACvC,OAAO,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AACzB,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;AAC/B,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,iBAAiB;IAC/B,QAAQ,CAAC,KAAK,EAAE,CAAA;IAChB,MAAM,EAAE,CAAA;AACV,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,cAAc,GACzB,qEAAqE;IACrE,kDAAkD;IAClD,yFAAyF,CAAA;AAE3F;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC,OAAO,CACtD,WAAW,EACX,wCAAwC,CACzC,CAAA"}
|
package/dist/toolbar.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbar.d.ts","sourceRoot":"","sources":["../src/toolbar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"toolbar.d.ts","sourceRoot":"","sources":["../src/toolbar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAWlD,MAAM,WAAW,cAAc;IAC7B,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAuDD,qBAAa,OAAO;;IAClB,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAA;gBAgBf,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,GAAE,cAAmB;IA8B1E,+CAA+C;IAC/C,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAM7B,OAAO,IAAI,IAAI;IA6Bf,2DAA2D;IAC3D,IAAI,UAAU,IAAI,cAAc,CAE/B;IAiSD;;;;;;;;;OASG;IACH,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,CAAC,EAAE,WAAW,GAAG,IAAI;IAgElD;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IA8F9E,iEAAiE;IACjE,YAAY,IAAI,IAAI;IAYpB,mEAAmE;IACnE,oBAAoB,IAAI,IAAI;CAG7B"}
|
package/dist/toolbar.js
CHANGED
|
@@ -69,6 +69,7 @@ export class Toolbar {
|
|
|
69
69
|
#host;
|
|
70
70
|
#view = null;
|
|
71
71
|
#controls = new Map();
|
|
72
|
+
#customs = [];
|
|
72
73
|
#select = null;
|
|
73
74
|
#live;
|
|
74
75
|
#liveTimer;
|
|
@@ -112,9 +113,30 @@ export class Toolbar {
|
|
|
112
113
|
this.#unsubscribe?.();
|
|
113
114
|
clearTimeout(this.#liveTimer);
|
|
114
115
|
this.el.removeEventListener('keydown', this.#onKeydown);
|
|
116
|
+
this.#destroyCustoms();
|
|
115
117
|
this.#controls.clear();
|
|
116
118
|
this.#view = null;
|
|
117
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Tear down `custom` controls.
|
|
122
|
+
*
|
|
123
|
+
* Called on destroy AND before every re-render. A custom control may have put
|
|
124
|
+
* a popover in the top layer, which is outside this element and therefore
|
|
125
|
+
* survives `replaceChildren` -- so without this, a registry change while a
|
|
126
|
+
* colour picker is open leaves an orphaned popover on the page with no trigger
|
|
127
|
+
* attached to it.
|
|
128
|
+
*/
|
|
129
|
+
#destroyCustoms() {
|
|
130
|
+
for (const { id, control } of this.#customs) {
|
|
131
|
+
try {
|
|
132
|
+
control.destroy?.();
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
console.error(`@openleaf-editor/ui: toolbar item "${id}" threw while being destroyed`, error);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
this.#customs = [];
|
|
139
|
+
}
|
|
118
140
|
/** The live region element, which the host mounts once. */
|
|
119
141
|
get liveRegion() {
|
|
120
142
|
return this.#live;
|
|
@@ -123,6 +145,7 @@ export class Toolbar {
|
|
|
123
145
|
* Rendering
|
|
124
146
|
* -------------------------------------------------------------- */
|
|
125
147
|
#render() {
|
|
148
|
+
this.#destroyCustoms();
|
|
126
149
|
this.el.replaceChildren();
|
|
127
150
|
this.#controls.clear();
|
|
128
151
|
this.#select = null;
|
|
@@ -146,10 +169,15 @@ export class Toolbar {
|
|
|
146
169
|
console.warn(`@openleaf-editor/ui: no toolbar item registered for "${token}"`);
|
|
147
170
|
continue;
|
|
148
171
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
172
|
+
if (spec.type === 'custom') {
|
|
173
|
+
const el = this.#buildCustom(spec);
|
|
174
|
+
if (el)
|
|
175
|
+
group.appendChild(el);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
// `select` is still unimplemented -- the block-type control is special-cased
|
|
179
|
+
// by id, not by type. A declared-and-inert variant is worse than an absent
|
|
180
|
+
// one, because the author sees a plausible button and no signal that the
|
|
153
181
|
// control they asked for was not built.
|
|
154
182
|
if (spec.type && spec.type !== 'button') {
|
|
155
183
|
console.warn(`@openleaf-editor/ui: toolbar item "${spec.id}" declares type "${spec.type}", ` +
|
|
@@ -239,6 +267,37 @@ export class Toolbar {
|
|
|
239
267
|
this.#controls.set(spec.id, { spec, el: button, active: null, enabled: null });
|
|
240
268
|
return button;
|
|
241
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Build a `custom` control.
|
|
272
|
+
*
|
|
273
|
+
* Everything the item does is third-party code running inside the editor's
|
|
274
|
+
* render path, so a throw here must cost that one control and nothing else: a
|
|
275
|
+
* colour picker that fails to build must not take the rest of the toolbar --
|
|
276
|
+
* and with it Bold, Undo and Save -- down with it.
|
|
277
|
+
*/
|
|
278
|
+
#buildCustom(spec) {
|
|
279
|
+
const view = this.#view;
|
|
280
|
+
if (!spec.render) {
|
|
281
|
+
console.warn(`@openleaf-editor/ui: toolbar item "${spec.id}" declares type "custom" but has no ` +
|
|
282
|
+
'render function, so there is nothing to build.');
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
// No view yet means this is a pre-mount re-render triggered by a late
|
|
286
|
+
// registration. mount() renders again with a view, so the control appears
|
|
287
|
+
// then rather than being built against nothing.
|
|
288
|
+
if (!view)
|
|
289
|
+
return null;
|
|
290
|
+
try {
|
|
291
|
+
const control = spec.render({ view, host: this.#host });
|
|
292
|
+
this.#customs.push({ id: spec.id, control });
|
|
293
|
+
return control.el;
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
console.error(`@openleaf-editor/ui: toolbar item "${spec.id}" threw while rendering. ` +
|
|
297
|
+
'It has been left out; the rest of the toolbar is unaffected.', error);
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
242
301
|
/**
|
|
243
302
|
* The block-type control.
|
|
244
303
|
*
|
|
@@ -384,6 +443,19 @@ export class Toolbar {
|
|
|
384
443
|
}
|
|
385
444
|
}
|
|
386
445
|
}
|
|
446
|
+
for (const { id, control } of this.#customs) {
|
|
447
|
+
// Readonly is the toolbar's business, not each control's: reflecting it
|
|
448
|
+
// here means a custom control gets the same disabled treatment as a button
|
|
449
|
+
// without every plugin author having to remember the attribute exists.
|
|
450
|
+
const trigger = control.el.querySelector('button.ol-btn');
|
|
451
|
+
trigger?.setAttribute('aria-disabled', this.#host.hasAttribute('readonly') ? 'true' : 'false');
|
|
452
|
+
if (!control.update)
|
|
453
|
+
continue;
|
|
454
|
+
guarded(id, 'update', () => {
|
|
455
|
+
control.update?.(state);
|
|
456
|
+
return true;
|
|
457
|
+
});
|
|
458
|
+
}
|
|
387
459
|
if (this.#select) {
|
|
388
460
|
const level = activeHeadingLevel(state);
|
|
389
461
|
const value = level === null ? 'p' : String(level);
|
package/dist/toolbar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbar.js","sourceRoot":"","sources":["../src/toolbar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAGpG,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,EACL,cAAc,EACd,cAAc,EACd,gBAAgB,GAEjB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAoB1C,MAAM,aAAa,GAAG,WAAW,CAAA;AAEjC,kFAAkF;AAClF,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAA;AAElC;;;;;;;;;;;;GAYG;AACH,SAAS,OAAO,CAAC,MAAc,EAAE,IAAY,EAAE,GAAkB;IAC/D,IAAI,CAAC;QACH,OAAO,GAAG,EAAE,CAAA;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,GAAG,GAAG,GAAG,MAAM,IAAI,IAAI,EAAE,CAAA;QAC/B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACjB,OAAO,CAAC,KAAK,CACX,4BAA4B,IAAI,gCAAgC,MAAM,WAAW;gBAC/E,4EAA4E;gBAC5E,wBAAwB,EAC1B,KAAK,CACN,C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GAAG,EAAE,CAAC;YAClB,KAAK,YAAY;gBACf,KAAK,CAAC,cAAc,EAAE,CAAA;gBACtB,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;gBACnB,MAAK;YACP,KAAK,WAAW;gBACd,KAAK,CAAC,cAAc,EAAE,CAAA;gBACtB,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;gBACpB,MAAK;YACP,KAAK,MAAM;gBACT,KAAK,CAAC,cAAc,EAAE,CAAA;gBACtB,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;gBAClB,MAAK;YACP,KAAK,KAAK;gBACR,KAAK,CAAC,cAAc,EAAE,CAAA;gBACtB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;gBAC5C,MAAK;YACP;gBACE,MAAK;QACT,CAAC;IACH,CAAC,CAAA;IAED,iEAAiE;IACjE,YAAY;QACV,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC,YAAY,EAAE,CAAA;YACnB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,CAAA;YAC5C,OAAM;QACR,CAAC;QACD,sEAAsE;QACtE,qEAAqE;QACrE,yDAAyD;QACzD,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,CAAA;IACvB,CAAC;IAED,mEAAmE;IACnE,oBAAoB;QAClB,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,CAAA;IACrB,CAAC;CACF"}
|
package/dist/upload.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image upload: the hook, and where the bytes are allowed to go.
|
|
3
|
+
*
|
|
4
|
+
* OpenLeaf has no server, so it cannot upload anything. What it can do is own
|
|
5
|
+
* the *flow* -- pick or drop a file, hand it to the host, get a URL back, ask for
|
|
6
|
+
* alternative text, insert -- and leave the transport to the one piece of the
|
|
7
|
+
* stack that knows the CMS's endpoint, its CSRF token and its media library.
|
|
8
|
+
*
|
|
9
|
+
* ## Why there is no data: URL fallback
|
|
10
|
+
*
|
|
11
|
+
* The tempting default for an editor with no server is to inline the file as a
|
|
12
|
+
* `data:` URI, so the feature "works" out of the box. Core refuses `data:` URLs
|
|
13
|
+
* on purpose -- `data:text/html` is a full XSS vector and separating the safe
|
|
14
|
+
* media types from the dangerous ones by sniffing is exactly the parsing that
|
|
15
|
+
* gets defeated -- and a fallback that silently produces content the schema will
|
|
16
|
+
* refuse on the next parse is worse than no fallback: the author sees their image
|
|
17
|
+
* appear, saves, and finds it gone.
|
|
18
|
+
*
|
|
19
|
+
* So with no uploader registered the file picker is not offered at all, and the
|
|
20
|
+
* dialog is what it has always been: insert by URL, with alt text.
|
|
21
|
+
*
|
|
22
|
+
* ## Registration
|
|
23
|
+
*
|
|
24
|
+
* Global by default, because that matches every other extension point here and
|
|
25
|
+
* because most pages have one upload endpoint:
|
|
26
|
+
*
|
|
27
|
+
* ```js
|
|
28
|
+
* OpenLeaf.registerImageUploader(async (file) => {
|
|
29
|
+
* const body = new FormData()
|
|
30
|
+
* body.append('file', file)
|
|
31
|
+
* const res = await fetch('/admin/media', { method: 'POST', body })
|
|
32
|
+
* if (!res.ok) throw new Error('The server rejected the upload.')
|
|
33
|
+
* const { url, width, height } = await res.json()
|
|
34
|
+
* return { src: url, width, height }
|
|
35
|
+
* })
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* A single page with two editors posting to different endpoints sets
|
|
39
|
+
* `element.imageUploader` instead, which takes precedence for that editor. Both
|
|
40
|
+
* exist because the global one is the common case and the per-editor one is the
|
|
41
|
+
* case that is impossible to express otherwise.
|
|
42
|
+
*/
|
|
43
|
+
/** What an uploader reports back. A bare string is shorthand for `{ src }`. */
|
|
44
|
+
export interface ImageUploadResult {
|
|
45
|
+
src: string;
|
|
46
|
+
/**
|
|
47
|
+
* Alternative text, if the media library already holds a description.
|
|
48
|
+
*
|
|
49
|
+
* Used to pre-fill the field the author is asked to confirm, never to skip
|
|
50
|
+
* asking: a filename-derived description is worse than none, because it looks
|
|
51
|
+
* like a description to everything except the person relying on it.
|
|
52
|
+
*/
|
|
53
|
+
alt?: string | null;
|
|
54
|
+
title?: string | null;
|
|
55
|
+
/** Intrinsic dimensions, which prevent the page reflowing as images load. */
|
|
56
|
+
width?: string | number | null;
|
|
57
|
+
height?: string | number | null;
|
|
58
|
+
}
|
|
59
|
+
export type ImageUploader = (file: File, context: {
|
|
60
|
+
host: HTMLElement;
|
|
61
|
+
}) => Promise<ImageUploadResult | string>;
|
|
62
|
+
/** Register the uploader for every editor on the page. `null` removes it. */
|
|
63
|
+
export declare function registerImageUploader(uploader: ImageUploader | null): void;
|
|
64
|
+
/** The uploader this editor should use: its own if it has one, else the global. */
|
|
65
|
+
export declare function imageUploaderFor(host: HTMLElement | null | undefined): ImageUploader | null;
|
|
66
|
+
/** Can this editor upload at all? Drives whether a file picker is offered. */
|
|
67
|
+
export declare function canUploadImages(host: HTMLElement | null | undefined): boolean;
|
|
68
|
+
/** What the file picker offers. Advisory: a picker's accept list is not a check. */
|
|
69
|
+
export declare const IMAGE_ACCEPT = "image/png,image/jpeg,image/gif,image/webp,image/avif";
|
|
70
|
+
/**
|
|
71
|
+
* Is this a file the image flow will accept?
|
|
72
|
+
*
|
|
73
|
+
* Any `image/*` except SVG, which is deliberately excluded. An SVG is a document,
|
|
74
|
+
* not a bitmap: it can carry `<script>` and event handlers, and while those do
|
|
75
|
+
* not execute in an `<img>`, the same file opened directly -- or embedded with
|
|
76
|
+
* `<object>` by some other part of the CMS -- is a stored XSS. Deciding an SVG is
|
|
77
|
+
* safe requires sanitizing its interior, which is a job for the server that
|
|
78
|
+
* accepts the upload, not for a drop handler.
|
|
79
|
+
*/
|
|
80
|
+
export declare function isUploadableImage(file: File): boolean;
|
|
81
|
+
/** The uploadable images in a drop or a paste, in the order they arrived. */
|
|
82
|
+
export declare function imageFilesFrom(transfer: DataTransfer | null | undefined): File[];
|
|
83
|
+
/**
|
|
84
|
+
* Run an uploader and normalize what it returns.
|
|
85
|
+
*
|
|
86
|
+
* Rejects a URL core would refuse rather than inserting it: an uploader that
|
|
87
|
+
* hands back `javascript:` -- through a compromised media library, or a
|
|
88
|
+
* misconfigured proxy that echoes a URL parameter -- would otherwise put it in
|
|
89
|
+
* the document, where the schema drops it on the next parse and the author
|
|
90
|
+
* cannot tell whether the upload or the editor lost their image.
|
|
91
|
+
*/
|
|
92
|
+
export declare function runUploader(uploader: ImageUploader, file: File, host: HTMLElement): Promise<ImageUploadResult>;
|
|
93
|
+
/** Dimensions as attribute strings, dropping anything that is not a number. */
|
|
94
|
+
export declare function dimension(value: string | number | null | undefined): string | null;
|
|
95
|
+
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAIH,+EAA+E;AAC/E,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAA;IACX;;;;;;OAMG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;CAChC;AAED,MAAM,MAAM,aAAa,GAAG,CAC1B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,KAC3B,OAAO,CAAC,iBAAiB,GAAG,MAAM,CAAC,CAAA;AASxC,6EAA6E;AAC7E,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,CAE1E;AAED,mFAAmF;AACnF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,aAAa,GAAG,IAAI,CAG3F;AAED,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAE7E;AAED,oFAAoF;AACpF,eAAO,MAAM,YAAY,yDAAyD,CAAA;AAElF;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAErD;AAED,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,EAAE,CAEhF;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,iBAAiB,CAAC,CAW5B;AAED,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAIlF"}
|
package/dist/upload.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image upload: the hook, and where the bytes are allowed to go.
|
|
3
|
+
*
|
|
4
|
+
* OpenLeaf has no server, so it cannot upload anything. What it can do is own
|
|
5
|
+
* the *flow* -- pick or drop a file, hand it to the host, get a URL back, ask for
|
|
6
|
+
* alternative text, insert -- and leave the transport to the one piece of the
|
|
7
|
+
* stack that knows the CMS's endpoint, its CSRF token and its media library.
|
|
8
|
+
*
|
|
9
|
+
* ## Why there is no data: URL fallback
|
|
10
|
+
*
|
|
11
|
+
* The tempting default for an editor with no server is to inline the file as a
|
|
12
|
+
* `data:` URI, so the feature "works" out of the box. Core refuses `data:` URLs
|
|
13
|
+
* on purpose -- `data:text/html` is a full XSS vector and separating the safe
|
|
14
|
+
* media types from the dangerous ones by sniffing is exactly the parsing that
|
|
15
|
+
* gets defeated -- and a fallback that silently produces content the schema will
|
|
16
|
+
* refuse on the next parse is worse than no fallback: the author sees their image
|
|
17
|
+
* appear, saves, and finds it gone.
|
|
18
|
+
*
|
|
19
|
+
* So with no uploader registered the file picker is not offered at all, and the
|
|
20
|
+
* dialog is what it has always been: insert by URL, with alt text.
|
|
21
|
+
*
|
|
22
|
+
* ## Registration
|
|
23
|
+
*
|
|
24
|
+
* Global by default, because that matches every other extension point here and
|
|
25
|
+
* because most pages have one upload endpoint:
|
|
26
|
+
*
|
|
27
|
+
* ```js
|
|
28
|
+
* OpenLeaf.registerImageUploader(async (file) => {
|
|
29
|
+
* const body = new FormData()
|
|
30
|
+
* body.append('file', file)
|
|
31
|
+
* const res = await fetch('/admin/media', { method: 'POST', body })
|
|
32
|
+
* if (!res.ok) throw new Error('The server rejected the upload.')
|
|
33
|
+
* const { url, width, height } = await res.json()
|
|
34
|
+
* return { src: url, width, height }
|
|
35
|
+
* })
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* A single page with two editors posting to different endpoints sets
|
|
39
|
+
* `element.imageUploader` instead, which takes precedence for that editor. Both
|
|
40
|
+
* exist because the global one is the common case and the per-editor one is the
|
|
41
|
+
* case that is impossible to express otherwise.
|
|
42
|
+
*/
|
|
43
|
+
import { isSafeUrl } from '@openleaf-editor/core';
|
|
44
|
+
let globalUploader = null;
|
|
45
|
+
/** Register the uploader for every editor on the page. `null` removes it. */
|
|
46
|
+
export function registerImageUploader(uploader) {
|
|
47
|
+
globalUploader = uploader;
|
|
48
|
+
}
|
|
49
|
+
/** The uploader this editor should use: its own if it has one, else the global. */
|
|
50
|
+
export function imageUploaderFor(host) {
|
|
51
|
+
const own = host?.imageUploader;
|
|
52
|
+
return own ?? globalUploader;
|
|
53
|
+
}
|
|
54
|
+
/** Can this editor upload at all? Drives whether a file picker is offered. */
|
|
55
|
+
export function canUploadImages(host) {
|
|
56
|
+
return imageUploaderFor(host) !== null;
|
|
57
|
+
}
|
|
58
|
+
/** What the file picker offers. Advisory: a picker's accept list is not a check. */
|
|
59
|
+
export const IMAGE_ACCEPT = 'image/png,image/jpeg,image/gif,image/webp,image/avif';
|
|
60
|
+
/**
|
|
61
|
+
* Is this a file the image flow will accept?
|
|
62
|
+
*
|
|
63
|
+
* Any `image/*` except SVG, which is deliberately excluded. An SVG is a document,
|
|
64
|
+
* not a bitmap: it can carry `<script>` and event handlers, and while those do
|
|
65
|
+
* not execute in an `<img>`, the same file opened directly -- or embedded with
|
|
66
|
+
* `<object>` by some other part of the CMS -- is a stored XSS. Deciding an SVG is
|
|
67
|
+
* safe requires sanitizing its interior, which is a job for the server that
|
|
68
|
+
* accepts the upload, not for a drop handler.
|
|
69
|
+
*/
|
|
70
|
+
export function isUploadableImage(file) {
|
|
71
|
+
return file.type.startsWith('image/') && file.type !== 'image/svg+xml';
|
|
72
|
+
}
|
|
73
|
+
/** The uploadable images in a drop or a paste, in the order they arrived. */
|
|
74
|
+
export function imageFilesFrom(transfer) {
|
|
75
|
+
return [...(transfer?.files ?? [])].filter(isUploadableImage);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Run an uploader and normalize what it returns.
|
|
79
|
+
*
|
|
80
|
+
* Rejects a URL core would refuse rather than inserting it: an uploader that
|
|
81
|
+
* hands back `javascript:` -- through a compromised media library, or a
|
|
82
|
+
* misconfigured proxy that echoes a URL parameter -- would otherwise put it in
|
|
83
|
+
* the document, where the schema drops it on the next parse and the author
|
|
84
|
+
* cannot tell whether the upload or the editor lost their image.
|
|
85
|
+
*/
|
|
86
|
+
export async function runUploader(uploader, file, host) {
|
|
87
|
+
const raw = await uploader(file, { host });
|
|
88
|
+
const result = typeof raw === 'string' ? { src: raw } : raw;
|
|
89
|
+
if (!result || typeof result.src !== 'string' || result.src === '') {
|
|
90
|
+
throw new Error('The upload finished but reported no address for the image.');
|
|
91
|
+
}
|
|
92
|
+
if (!isSafeUrl(result.src)) {
|
|
93
|
+
throw new Error('The upload reported an address the editor will not store.');
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
/** Dimensions as attribute strings, dropping anything that is not a number. */
|
|
98
|
+
export function dimension(value) {
|
|
99
|
+
if (value === null || value === undefined || value === '')
|
|
100
|
+
return null;
|
|
101
|
+
const number = typeof value === 'number' ? value : Number.parseFloat(value);
|
|
102
|
+
return Number.isFinite(number) && number > 0 ? String(Math.round(number)) : null;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AA6BjD,IAAI,cAAc,GAAyB,IAAI,CAAA;AAE/C,6EAA6E;AAC7E,MAAM,UAAU,qBAAqB,CAAC,QAA8B;IAClE,cAAc,GAAG,QAAQ,CAAA;AAC3B,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,gBAAgB,CAAC,IAAoC;IACnE,MAAM,GAAG,GAAI,IAA4C,EAAE,aAAa,CAAA;IACxE,OAAO,GAAG,IAAI,cAAc,CAAA;AAC9B,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,eAAe,CAAC,IAAoC;IAClE,OAAO,gBAAgB,CAAC,IAAI,CAAC,KAAK,IAAI,CAAA;AACxC,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,MAAM,YAAY,GAAG,sDAAsD,CAAA;AAElF;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAU;IAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,IAA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