mechanica 2.0.0-alpha.0 → 2.0.0-alpha.10
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/README.md +2 -2
- package/dist/chunks/{ImagePickerDialog-DZyxrbfv.js → ImagePickerDialog-CY-mn2UP.js} +418 -14
- package/dist/chunks/create-mechanica-CnBFiyfJ.js +721 -0
- package/dist/chunks/editor-9tquvDcS.js +3240 -0
- package/dist/chunks/page-assets-DbE_sYLq.js +986 -0
- package/dist/chunks/preview-G5_AFI5P.js +173 -0
- package/dist/cli.js +0 -0
- package/dist/composer.js +4968 -0
- package/dist/editor.css +4180 -1468
- package/dist/editor.js +915 -2657
- package/dist/index.js +149 -9
- package/dist/plugin.js +1060 -73
- package/dist/types/cli/build.d.ts +4 -4
- package/dist/types/cli/export.d.ts +35 -5
- package/dist/types/cli/images.d.ts +15 -0
- package/dist/types/cli/page-assets.d.ts +7 -0
- package/dist/types/cli/thumbs.d.ts +1 -1
- package/dist/types/core/composed.d.ts +15 -0
- package/dist/types/core/composer-components.d.ts +26 -0
- package/dist/types/core/create-mechanica.d.ts +8 -1
- package/dist/types/core/data-registry.d.ts +3 -1
- package/dist/types/core/define-data.d.ts +6 -0
- package/dist/types/core/define-mechanica-app.d.ts +2 -1
- package/dist/types/core/field-types.d.ts +18 -1
- package/dist/types/core/image.d.ts +71 -0
- package/dist/types/core/index.d.ts +6 -0
- package/dist/types/core/link.d.ts +33 -4
- package/dist/types/core/load-blocks.d.ts +10 -4
- package/dist/types/core/preview.d.ts +1 -1
- package/dist/types/core/render-blocks.d.ts +8 -1
- package/dist/types/core/router.d.ts +1 -1
- package/dist/types/core/state.d.ts +3 -1
- package/dist/types/core/use-locale.d.ts +25 -0
- package/dist/types/core/use-page-data.d.ts +1 -1
- package/dist/types/editor/composer/composer.d.ts +36 -0
- package/dist/types/editor/composer/lib/abs.d.ts +58 -0
- package/dist/types/editor/composer/lib/canvas-drop-target.d.ts +26 -0
- package/dist/types/editor/composer/lib/canvas-drop.d.ts +37 -0
- package/dist/types/editor/composer/lib/canvas-overlay.d.ts +77 -0
- package/dist/types/editor/composer/lib/canvas-view.d.ts +34 -0
- package/dist/types/editor/composer/lib/canvas.d.ts +24 -0
- package/dist/types/editor/composer/lib/class-css.d.ts +43 -0
- package/dist/types/editor/composer/lib/class-groups.d.ts +35 -0
- package/dist/types/editor/composer/lib/clipboard.d.ts +13 -0
- package/dist/types/editor/composer/lib/composer-history.d.ts +17 -0
- package/dist/types/editor/composer/lib/composer-store.d.ts +123 -0
- package/dist/types/editor/composer/lib/design-tokens.d.ts +13 -0
- package/dist/types/editor/composer/lib/elements-meta.d.ts +39 -0
- package/dist/types/editor/composer/lib/inspector-props.d.ts +38 -0
- package/dist/types/editor/composer/lib/keys.d.ts +13 -0
- package/dist/types/editor/composer/lib/marquee.d.ts +10 -0
- package/dist/types/editor/composer/lib/normalize-template.d.ts +29 -0
- package/dist/types/editor/composer/lib/padding.d.ts +32 -0
- package/dist/types/editor/composer/lib/scrub.d.ts +6 -0
- package/dist/types/editor/composer/lib/use-insert-dnd.d.ts +33 -0
- package/dist/types/editor/composer/lib/use-layer-dnd.d.ts +22 -0
- package/dist/types/editor/fields/registry.d.ts +1 -1
- package/dist/types/editor/lib/block-meta.d.ts +8 -1
- package/dist/types/editor/lib/bridge.d.ts +1 -1
- package/dist/types/editor/lib/content-tree.d.ts +1 -1
- package/dist/types/editor/lib/context-menu.d.ts +2 -0
- package/dist/types/editor/lib/image-crop.d.ts +70 -0
- package/dist/types/editor/lib/image-size.d.ts +55 -0
- package/dist/types/editor/lib/keyboard.d.ts +19 -0
- package/dist/types/editor/lib/page-list.d.ts +16 -0
- package/dist/types/editor/lib/shortcuts.d.ts +4 -1
- package/dist/types/editor/lib/store.d.ts +17 -1
- package/dist/types/editor/lib/typography.d.ts +39 -0
- package/dist/types/editor/widget-api.d.ts +4 -1
- package/dist/types/elements/emit-css.d.ts +31 -0
- package/dist/types/elements/index.d.ts +9 -0
- package/dist/types/elements/style-vars.d.ts +48 -0
- package/dist/types/vite/collect-components.d.ts +19 -0
- package/dist/types/vite/collect-composed.d.ts +15 -0
- package/dist/types/vite/dev/assets-store.d.ts +50 -2
- package/dist/types/vite/dev/composed-store.d.ts +41 -0
- package/dist/types/vite/dev/composer.d.ts +15 -0
- package/dist/types/vite/dev/data-store.d.ts +20 -4
- package/dist/types/vite/dev/image-preview.d.ts +46 -0
- package/dist/types/vite/dev/middleware.d.ts +14 -0
- package/dist/types/vite/dev/page-state.d.ts +33 -3
- package/dist/types/vite/dev/pages-store.d.ts +89 -18
- package/dist/types/vite/dev/query-dev.d.ts +5 -4
- package/dist/types/vite/entries.d.ts +35 -0
- package/dist/types/vite/generate-pages.d.ts +35 -0
- package/dist/types/vite/index.d.ts +1 -0
- package/dist/types/vite/plugin.d.ts +64 -0
- package/dist/types/vite/read-breakpoints.d.ts +17 -0
- package/dist/types/vite/rich-text-codec.d.ts +1 -1
- package/dist/widgets.js +1 -1
- package/package.json +7 -3
- package/src/cli/build.ts +5 -6
- package/src/cli/cli.ts +18 -2
- package/src/cli/export.ts +0 -0
- package/src/cli/images.ts +67 -0
- package/src/cli/page-assets.ts +10 -2
- package/src/cli/shot.ts +14 -6
- package/src/cli/thumbs.ts +14 -6
- package/src/core/composed.ts +45 -0
- package/src/core/composer-components.ts +31 -0
- package/src/core/create-mechanica.ts +21 -2
- package/src/core/data-registry.ts +4 -1
- package/src/core/define-data.ts +7 -1
- package/src/core/define-mechanica-app.ts +3 -1
- package/src/core/field-types.ts +17 -2
- package/src/core/image.ts +107 -0
- package/src/core/index.ts +9 -0
- package/src/core/link.ts +23 -6
- package/src/core/load-blocks.ts +25 -4
- package/src/core/preview.ts +10 -1
- package/src/core/render-blocks.ts +36 -12
- package/src/core/router.ts +1 -1
- package/src/core/state.ts +3 -1
- package/src/core/use-locale.ts +40 -0
- package/src/core/use-page-data.ts +1 -1
- package/src/editor/EditorApp.vue +52 -6
- package/src/editor/components/BlockPalette.vue +91 -1
- package/src/editor/components/BlockPreview.vue +1 -1
- package/src/editor/components/BlockSettings.vue +43 -1
- package/src/editor/components/DataSettings.vue +73 -59
- package/src/editor/components/HierarchyTree.vue +1 -1
- package/src/editor/components/IconField.vue +201 -0
- package/src/editor/components/LocaleSwitcher.vue +239 -0
- package/src/editor/components/TypographyInput.vue +131 -0
- package/src/editor/components/VContextMenu.vue +9 -1
- package/src/editor/components/VPopover.vue +8 -2
- package/src/editor/components/VSegmented.vue +93 -0
- package/src/editor/components/VSelect.vue +38 -16
- package/src/editor/composer/ComposerApp.vue +220 -0
- package/src/editor/composer/components/AlignGrid.vue +74 -0
- package/src/editor/composer/components/AnchorGrid.vue +36 -0
- package/src/editor/composer/components/BindField.vue +42 -0
- package/src/editor/composer/components/BoxSideInput.vue +141 -0
- package/src/editor/composer/components/CanvasOverlay.vue +488 -0
- package/src/editor/composer/components/ClassStylePreview.vue +82 -0
- package/src/editor/composer/components/ColorField.vue +36 -0
- package/src/editor/composer/components/ComponentFields.vue +39 -0
- package/src/editor/composer/components/ComposerCanvas.vue +376 -0
- package/src/editor/composer/components/ComposerInspector.vue +506 -0
- package/src/editor/composer/components/ComposerLayers.vue +28 -0
- package/src/editor/composer/components/ComposerSettings.vue +52 -0
- package/src/editor/composer/components/InsertToolbar.vue +96 -0
- package/src/editor/composer/components/LayerNode.vue +69 -0
- package/src/editor/composer/components/MultiSelectPanel.vue +57 -0
- package/src/editor/composer/components/NumInput.vue +121 -0
- package/src/editor/composer/components/OverrideLabel.vue +21 -0
- package/src/editor/composer/components/PropToggle.vue +42 -0
- package/src/editor/composer/components/PropsSection.vue +51 -0
- package/src/editor/composer/components/SegControl.vue +30 -0
- package/src/editor/composer/components/SizeInput.vue +62 -0
- package/src/editor/composer/composer.ts +220 -0
- package/src/editor/composer/lib/abs.ts +78 -0
- package/src/editor/composer/lib/canvas-drop-target.ts +103 -0
- package/src/editor/composer/lib/canvas-drop.ts +78 -0
- package/src/editor/composer/lib/canvas-overlay.ts +168 -0
- package/src/editor/composer/lib/canvas-view.ts +75 -0
- package/src/editor/composer/lib/canvas.ts +65 -0
- package/src/editor/composer/lib/class-css.ts +103 -0
- package/src/editor/composer/lib/class-groups.ts +86 -0
- package/src/editor/composer/lib/clipboard.ts +25 -0
- package/src/editor/composer/lib/composer-history.ts +81 -0
- package/src/editor/composer/lib/composer-store.ts +546 -0
- package/src/editor/composer/lib/design-tokens.ts +46 -0
- package/src/editor/composer/lib/elements-meta.ts +123 -0
- package/src/editor/composer/lib/inspector-props.ts +76 -0
- package/src/editor/composer/lib/keys.ts +14 -0
- package/src/editor/composer/lib/marquee.ts +26 -0
- package/src/editor/composer/lib/normalize-template.ts +51 -0
- package/src/editor/composer/lib/padding.ts +71 -0
- package/src/editor/composer/lib/scrub.ts +9 -0
- package/src/editor/composer/lib/use-insert-dnd.ts +131 -0
- package/src/editor/composer/lib/use-layer-dnd.ts +99 -0
- package/src/editor/composer/styles/composer.scss +1657 -0
- package/src/editor/dialogs/ImageCropDialog.vue +360 -0
- package/src/editor/dialogs/ImagePickerDialog.vue +34 -5
- package/src/editor/dialogs/PageFormDialog.vue +127 -0
- package/src/editor/dialogs/PagesDialog.vue +657 -260
- package/src/editor/editor.ts +82 -8
- package/src/editor/fields/editors/ImageField.vue +61 -15
- package/src/editor/fields/editors/StringField.vue +4 -6
- package/src/editor/fields/editors/TextField.vue +6 -6
- package/src/editor/fields/registry.ts +1 -1
- package/src/editor/fields/richtext/RichTableWidget.vue +63 -21
- package/src/editor/fields/richtext/RichTextEditor.vue +288 -108
- package/src/editor/fields/richtext/config.ts +6 -0
- package/src/editor/icons/align-center.svg +1 -0
- package/src/editor/icons/align-left.svg +1 -0
- package/src/editor/icons/align-right.svg +1 -0
- package/src/editor/icons/bolt.svg +1 -0
- package/src/editor/icons/button.svg +1 -0
- package/src/editor/icons/column.svg +1 -0
- package/src/editor/icons/component.svg +1 -0
- package/src/editor/icons/corner.svg +1 -0
- package/src/editor/icons/desktop.svg +1 -0
- package/src/editor/icons/fill.svg +1 -0
- package/src/editor/icons/frame.svg +1 -0
- package/src/editor/icons/gap.svg +1 -0
- package/src/editor/icons/globe.svg +1 -0
- package/src/editor/icons/height.svg +1 -0
- package/src/editor/icons/limits.svg +1 -0
- package/src/editor/icons/margin.svg +1 -0
- package/src/editor/icons/mobile.svg +1 -0
- package/src/editor/icons/position.svg +1 -0
- package/src/editor/icons/row.svg +1 -0
- package/src/editor/icons/sides.svg +1 -0
- package/src/editor/icons/tablet.svg +1 -0
- package/src/editor/icons/text.svg +1 -0
- package/src/editor/icons/width.svg +1 -0
- package/src/editor/icons/wrap.svg +1 -0
- package/src/editor/lib/block-meta.ts +27 -1
- package/src/editor/lib/block-preview.ts +10 -4
- package/src/editor/lib/bridge.ts +1 -1
- package/src/editor/lib/content-tree.ts +1 -1
- package/src/editor/lib/context-menu.ts +2 -0
- package/src/editor/lib/image-crop.ts +174 -0
- package/src/editor/lib/image-size.ts +154 -0
- package/src/editor/lib/keyboard.ts +29 -0
- package/src/editor/lib/page-list.ts +27 -0
- package/src/editor/lib/shortcuts.ts +7 -2
- package/src/editor/lib/store.ts +37 -1
- package/src/editor/lib/typography.ts +80 -0
- package/src/editor/props-panel/ArrayField.vue +1 -1
- package/src/editor/props-panel/SchemaForm.vue +108 -9
- package/src/editor/styles/_variables.scss +1 -1
- package/src/editor/ui/VDialogHost.vue +8 -0
- package/src/editor/widget-api.ts +5 -2
- package/src/elements/elements.scss +69 -0
- package/src/elements/emit-css.ts +153 -0
- package/src/elements/index.ts +135 -0
- package/src/elements/style-vars.ts +230 -0
- package/src/virtual-modules.d.ts +5 -0
- package/src/vite/collect-components.ts +58 -0
- package/src/vite/collect-composed.ts +49 -0
- package/src/vite/dev/assets-store.ts +182 -10
- package/src/vite/dev/composed-store.ts +99 -0
- package/src/vite/dev/composer.ts +46 -0
- package/src/vite/dev/data-store.ts +94 -8
- package/src/vite/dev/image-preview.ts +102 -0
- package/src/vite/dev/middleware.ts +210 -12
- package/src/vite/dev/page-state.ts +116 -9
- package/src/vite/dev/pages-store.ts +335 -42
- package/src/vite/dev/preview.ts +1 -1
- package/src/vite/dev/query-dev.ts +12 -6
- package/src/vite/entries.ts +82 -6
- package/src/vite/generate-pages.ts +51 -0
- package/src/vite/index.ts +1 -0
- package/src/vite/plugin.ts +271 -14
- package/src/vite/read-breakpoints.ts +47 -0
- package/src/vite/rich-text-codec.ts +1 -1
- package/dist/chunks/page-assets-DnDUQegn.js +0 -534
- package/dist/chunks/preview-uxnrJ5vY.js +0 -431
package/README.md
CHANGED
|
@@ -9,8 +9,8 @@ Built for **Vite 8 / Vue 3.5 / Bun**.
|
|
|
9
9
|
Works with plain Node ≥ 20.19 (npm/pnpm/yarn) or [Bun](https://bun.sh) — Bun installs run the TypeScript source directly, Node uses the compiled build. The fastest start is the scaffolder:
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
npm create mechanica
|
|
13
|
-
# or: bun create mechanica
|
|
12
|
+
npm create mechanica@latest my-site
|
|
13
|
+
# or: bun create mechanica my-site
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
Or add it to an existing Vite + Vue project:
|
|
@@ -1,38 +1,99 @@
|
|
|
1
1
|
import { Fragment, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, inject, mergeProps, normalizeClass, onMounted, openBlock, ref, renderList, renderSlot, shallowReactive, toDisplayString, unref, withCtx, withModifiers } from "vue";
|
|
2
|
+
//#region \0plugin-vue:export-helper
|
|
3
|
+
var _plugin_vue_export_helper_default = (sfc, props) => {
|
|
4
|
+
const target = sfc.__vccOpts || sfc;
|
|
5
|
+
for (const [key, val] of props) target[key] = val;
|
|
6
|
+
return target;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
2
9
|
//#region \0svg-glob:C:\Users\Den\Desktop\CURVES\mechanica\packages\mechanica\src\editor\icons
|
|
3
10
|
var contents = {
|
|
11
|
+
"align-center": `<path d="M4 6h16M7 12h10M6 18h12"/>`,
|
|
12
|
+
"align-left": `<path d="M4 6h16M4 12h10M4 18h13"/>`,
|
|
13
|
+
"align-right": `<path d="M4 6h16M10 12h10M7 18h13"/>`,
|
|
4
14
|
"arrow-down": `<path d="M12 5v14"/><path d="m19 12-7 7-7-7"/>`,
|
|
5
15
|
"arrow-up": `<path d="M12 19V5"/><path d="m5 12 7-7 7 7"/>`,
|
|
6
16
|
"bold": `<path d="M6 4h7a4 4 0 0 1 0 8H6z"/><path d="M6 12h8a4 4 0 0 1 0 8H6z"/>`,
|
|
17
|
+
"bolt": `<path d="M13 2 4.5 13.5H11l-1 8.5 8.5-11.5H12z"/>`,
|
|
7
18
|
"book": `<path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"/><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"/>`,
|
|
19
|
+
"button": `<rect x="3" y="8" width="18" height="8" rx="4"/><path d="M8 12h8"/>`,
|
|
8
20
|
"check": `<polyline points="20 6 9 17 4 12"/>`,
|
|
9
21
|
"chevron-down": `<path d="m6 9 6 6 6-6"/>`,
|
|
10
22
|
"close": `<path d="M18 6 6 18"/><path d="m6 6 12 12"/>`,
|
|
11
23
|
"code": `<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>`,
|
|
24
|
+
"column": `<rect x="5" y="4" width="14" height="6.5" rx="1.6"/><rect x="5" y="13.5" width="14" height="6.5" rx="1.6"/>`,
|
|
25
|
+
"component": `<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/>`,
|
|
12
26
|
"copy": `<rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>`,
|
|
27
|
+
"corner": `<path d="M5 20v-9a6 6 0 0 1 6-6h9"/>`,
|
|
28
|
+
"desktop": `<rect x="3" y="4.5" width="18" height="12.5" rx="2"/><path d="M12 17v3"/><path d="M8.5 20.5h7"/>`,
|
|
13
29
|
"ellipsis": `<circle cx="5" cy="12" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="19" cy="12" r="2"/>`,
|
|
30
|
+
"fill": `<path d="M12 3.5c3.2 3.7 5.5 6.9 5.5 9.7a5.5 5.5 0 0 1-11 0c0-2.8 2.3-6 5.5-9.7z"/>`,
|
|
14
31
|
"folder": `<path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>`,
|
|
32
|
+
"frame": `<rect x="4" y="4" width="16" height="16" rx="2"/><path d="M4 9.5h16M9.5 9.5V20"/>`,
|
|
33
|
+
"gap": `<rect x="2.5" y="5" width="5" height="14" rx="1.5"/><rect x="16.5" y="5" width="5" height="14" rx="1.5"/><path d="M9 12h6"/><path d="m10.5 10-1.5 2 1.5 2"/><path d="m13.5 10 1.5 2-1.5 2"/>`,
|
|
34
|
+
"globe": `<circle cx="12" cy="12" r="9"/><path d="M3 12h18"/><path d="M12 3a13.5 13.5 0 0 1 0 18a13.5 13.5 0 0 1 0-18"/>`,
|
|
15
35
|
"grip": `<circle cx="9" cy="5" r="1.6"/><circle cx="9" cy="12" r="1.6"/><circle cx="9" cy="19" r="1.6"/><circle cx="15" cy="5" r="1.6"/><circle cx="15" cy="12" r="1.6"/><circle cx="15" cy="19" r="1.6"/>`,
|
|
36
|
+
"height": `<path d="M5 4h14"/><path d="M5 20h14"/><path d="M12 8v8"/><path d="m9.5 10.5 2.5-2.5 2.5 2.5"/><path d="m9.5 13.5 2.5 2.5 2.5-2.5"/>`,
|
|
16
37
|
"image": `<rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>`,
|
|
17
38
|
"info": `<circle cx="12" cy="12" r="9"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12.01" y2="8"/>`,
|
|
18
39
|
"italic": `<line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/>`,
|
|
40
|
+
"limits": `<rect x="3" y="3" width="18" height="18" rx="2"/><rect x="8" y="8" width="8" height="8" rx="1.5" stroke-dasharray="2.5 2.5"/>`,
|
|
41
|
+
"margin": `<rect x="8" y="8" width="8" height="8" rx="1"/><path d="M12 2.5v3"/><path d="M12 18.5v3"/><path d="M2.5 12h3"/><path d="M18.5 12h3"/>`,
|
|
19
42
|
"menu": `<path d="M3 6h18"/><path d="M3 12h18"/><path d="M3 18h18"/>`,
|
|
43
|
+
"mobile": `<rect x="7" y="2.5" width="10" height="19" rx="2.2"/><path d="M10.75 18.25h2.5"/>`,
|
|
20
44
|
"named-slots": `<rect x="4" y="4" width="16" height="16" rx="2.5" stroke-dasharray="3.5 3"/><path d="M12 4.5v15"/>`,
|
|
21
45
|
"pencil": `<path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z"/>`,
|
|
22
46
|
"plus": `<path d="M12 5v14"/><path d="M5 12h14"/>`,
|
|
47
|
+
"position": `<circle cx="12" cy="12" r="5"/><path d="M12 2.5V5"/><path d="M12 19v2.5"/><path d="M2.5 12H5"/><path d="M19 12h2.5"/>`,
|
|
23
48
|
"redo": `<path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"/>`,
|
|
49
|
+
"row": `<rect x="4" y="5" width="6.5" height="14" rx="1.6"/><rect x="13.5" y="5" width="6.5" height="14" rx="1.6"/>`,
|
|
24
50
|
"search": `<circle cx="11" cy="11" r="7"/><path d="m21 21-4.35-4.35"/>`,
|
|
51
|
+
"sides": `<rect x="4" y="4" width="16" height="16" rx="2"/><rect x="9" y="9" width="6" height="6" rx="1"/>`,
|
|
25
52
|
"sliders": `<line x1="21" x2="14" y1="4" y2="4"/><line x1="10" x2="3" y1="4" y2="4"/><line x1="21" x2="12" y1="12" y2="12"/><line x1="8" x2="3" y1="12" y2="12"/><line x1="21" x2="16" y1="20" y2="20"/><line x1="12" x2="3" y1="20" y2="20"/><line x1="14" x2="14" y1="2" y2="6"/><line x1="8" x2="8" y1="10" y2="14"/><line x1="16" x2="16" y1="18" y2="22"/>`,
|
|
26
53
|
"slot": `<rect x="4" y="4" width="16" height="16" rx="2.5" stroke-dasharray="3.5 3"/>`,
|
|
27
54
|
"strikethrough": `<path d="M16 4H9a3 3 0 0 0-2.83 4"/><path d="M14 12a4 4 0 0 1 0 8H6"/><line x1="4" y1="12" x2="20" y2="12"/>`,
|
|
28
55
|
"table": `<rect x="3" y="4" width="18" height="16" rx="2" stroke="currentColor" stroke-width="2"/>
|
|
29
56
|
<path d="M3 9.5H21M9.5 9.5V20M15.5 9.5V20" stroke="currentColor" stroke-width="2"/>`,
|
|
57
|
+
"tablet": `<rect x="4.5" y="3" width="15" height="18" rx="2"/><path d="M10.5 17.75h3"/>`,
|
|
58
|
+
"text": `<path d="M5 6.5V5h14v1.5M12 5v14M9.5 19h5"/>`,
|
|
30
59
|
"trash": `<path d="M3 6h18"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><path d="M10 11v6"/><path d="M14 11v6"/>`,
|
|
31
60
|
"underline": `<path d="M6 4v6a6 6 0 0 0 12 0V4"/><line x1="4" y1="21" x2="20" y2="21"/>`,
|
|
32
61
|
"undo": `<path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/>`,
|
|
33
|
-
"upload": `<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"
|
|
62
|
+
"upload": `<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/>`,
|
|
63
|
+
"width": `<path d="M4 5v14"/><path d="M20 5v14"/><path d="M8 12h8"/><path d="m10.5 9.5-2.5 2.5 2.5 2.5"/><path d="m13.5 9.5 2.5 2.5-2.5 2.5"/>`,
|
|
64
|
+
"wrap": `<path d="M4 7h16M4 17h5"/><path d="M4 12h13a3 3 0 0 1 0 6h-2m2 0-2-2m2 2-2 2"/>`
|
|
34
65
|
};
|
|
35
66
|
var attrs = {
|
|
67
|
+
"align-center": {
|
|
68
|
+
"width": "24",
|
|
69
|
+
"height": "24",
|
|
70
|
+
"viewBox": "0 0 24 24",
|
|
71
|
+
"fill": "none",
|
|
72
|
+
"stroke": "currentColor",
|
|
73
|
+
"stroke-width": "1.6",
|
|
74
|
+
"stroke-linecap": "round",
|
|
75
|
+
"stroke-linejoin": "round"
|
|
76
|
+
},
|
|
77
|
+
"align-left": {
|
|
78
|
+
"width": "24",
|
|
79
|
+
"height": "24",
|
|
80
|
+
"viewBox": "0 0 24 24",
|
|
81
|
+
"fill": "none",
|
|
82
|
+
"stroke": "currentColor",
|
|
83
|
+
"stroke-width": "1.6",
|
|
84
|
+
"stroke-linecap": "round",
|
|
85
|
+
"stroke-linejoin": "round"
|
|
86
|
+
},
|
|
87
|
+
"align-right": {
|
|
88
|
+
"width": "24",
|
|
89
|
+
"height": "24",
|
|
90
|
+
"viewBox": "0 0 24 24",
|
|
91
|
+
"fill": "none",
|
|
92
|
+
"stroke": "currentColor",
|
|
93
|
+
"stroke-width": "1.6",
|
|
94
|
+
"stroke-linecap": "round",
|
|
95
|
+
"stroke-linejoin": "round"
|
|
96
|
+
},
|
|
36
97
|
"arrow-down": {
|
|
37
98
|
"viewBox": "0 0 24 24",
|
|
38
99
|
"fill": "none",
|
|
@@ -57,6 +118,16 @@ var attrs = {
|
|
|
57
118
|
"stroke-linecap": "round",
|
|
58
119
|
"stroke-linejoin": "round"
|
|
59
120
|
},
|
|
121
|
+
"bolt": {
|
|
122
|
+
"width": "24",
|
|
123
|
+
"height": "24",
|
|
124
|
+
"viewBox": "0 0 24 24",
|
|
125
|
+
"fill": "none",
|
|
126
|
+
"stroke": "currentColor",
|
|
127
|
+
"stroke-width": "1.6",
|
|
128
|
+
"stroke-linecap": "round",
|
|
129
|
+
"stroke-linejoin": "round"
|
|
130
|
+
},
|
|
60
131
|
"book": {
|
|
61
132
|
"viewBox": "0 0 24 24",
|
|
62
133
|
"fill": "none",
|
|
@@ -65,6 +136,16 @@ var attrs = {
|
|
|
65
136
|
"stroke-linecap": "round",
|
|
66
137
|
"stroke-linejoin": "round"
|
|
67
138
|
},
|
|
139
|
+
"button": {
|
|
140
|
+
"width": "24",
|
|
141
|
+
"height": "24",
|
|
142
|
+
"viewBox": "0 0 24 24",
|
|
143
|
+
"fill": "none",
|
|
144
|
+
"stroke": "currentColor",
|
|
145
|
+
"stroke-width": "1.6",
|
|
146
|
+
"stroke-linecap": "round",
|
|
147
|
+
"stroke-linejoin": "round"
|
|
148
|
+
},
|
|
68
149
|
"check": {
|
|
69
150
|
"viewBox": "0 0 24 24",
|
|
70
151
|
"fill": "none",
|
|
@@ -97,6 +178,26 @@ var attrs = {
|
|
|
97
178
|
"stroke-linecap": "round",
|
|
98
179
|
"stroke-linejoin": "round"
|
|
99
180
|
},
|
|
181
|
+
"column": {
|
|
182
|
+
"width": "24",
|
|
183
|
+
"height": "24",
|
|
184
|
+
"viewBox": "0 0 24 24",
|
|
185
|
+
"fill": "none",
|
|
186
|
+
"stroke": "currentColor",
|
|
187
|
+
"stroke-width": "1.6",
|
|
188
|
+
"stroke-linecap": "round",
|
|
189
|
+
"stroke-linejoin": "round"
|
|
190
|
+
},
|
|
191
|
+
"component": {
|
|
192
|
+
"width": "24",
|
|
193
|
+
"height": "24",
|
|
194
|
+
"viewBox": "0 0 24 24",
|
|
195
|
+
"fill": "none",
|
|
196
|
+
"stroke": "currentColor",
|
|
197
|
+
"stroke-width": "1.6",
|
|
198
|
+
"stroke-linecap": "round",
|
|
199
|
+
"stroke-linejoin": "round"
|
|
200
|
+
},
|
|
100
201
|
"copy": {
|
|
101
202
|
"viewBox": "0 0 24 24",
|
|
102
203
|
"fill": "none",
|
|
@@ -105,10 +206,40 @@ var attrs = {
|
|
|
105
206
|
"stroke-linecap": "round",
|
|
106
207
|
"stroke-linejoin": "round"
|
|
107
208
|
},
|
|
209
|
+
"corner": {
|
|
210
|
+
"width": "24",
|
|
211
|
+
"height": "24",
|
|
212
|
+
"viewBox": "0 0 24 24",
|
|
213
|
+
"fill": "none",
|
|
214
|
+
"stroke": "currentColor",
|
|
215
|
+
"stroke-width": "1.6",
|
|
216
|
+
"stroke-linecap": "round",
|
|
217
|
+
"stroke-linejoin": "round"
|
|
218
|
+
},
|
|
219
|
+
"desktop": {
|
|
220
|
+
"width": "24",
|
|
221
|
+
"height": "24",
|
|
222
|
+
"viewBox": "0 0 24 24",
|
|
223
|
+
"fill": "none",
|
|
224
|
+
"stroke": "currentColor",
|
|
225
|
+
"stroke-width": "1.6",
|
|
226
|
+
"stroke-linecap": "round",
|
|
227
|
+
"stroke-linejoin": "round"
|
|
228
|
+
},
|
|
108
229
|
"ellipsis": {
|
|
109
230
|
"viewBox": "0 0 24 24",
|
|
110
231
|
"fill": "currentColor"
|
|
111
232
|
},
|
|
233
|
+
"fill": {
|
|
234
|
+
"width": "24",
|
|
235
|
+
"height": "24",
|
|
236
|
+
"viewBox": "0 0 24 24",
|
|
237
|
+
"fill": "none",
|
|
238
|
+
"stroke": "currentColor",
|
|
239
|
+
"stroke-width": "1.6",
|
|
240
|
+
"stroke-linecap": "round",
|
|
241
|
+
"stroke-linejoin": "round"
|
|
242
|
+
},
|
|
112
243
|
"folder": {
|
|
113
244
|
"viewBox": "0 0 24 24",
|
|
114
245
|
"fill": "none",
|
|
@@ -117,11 +248,51 @@ var attrs = {
|
|
|
117
248
|
"stroke-linecap": "round",
|
|
118
249
|
"stroke-linejoin": "round"
|
|
119
250
|
},
|
|
251
|
+
"frame": {
|
|
252
|
+
"width": "24",
|
|
253
|
+
"height": "24",
|
|
254
|
+
"viewBox": "0 0 24 24",
|
|
255
|
+
"fill": "none",
|
|
256
|
+
"stroke": "currentColor",
|
|
257
|
+
"stroke-width": "1.6",
|
|
258
|
+
"stroke-linecap": "round",
|
|
259
|
+
"stroke-linejoin": "round"
|
|
260
|
+
},
|
|
261
|
+
"gap": {
|
|
262
|
+
"width": "24",
|
|
263
|
+
"height": "24",
|
|
264
|
+
"viewBox": "0 0 24 24",
|
|
265
|
+
"fill": "none",
|
|
266
|
+
"stroke": "currentColor",
|
|
267
|
+
"stroke-width": "1.6",
|
|
268
|
+
"stroke-linecap": "round",
|
|
269
|
+
"stroke-linejoin": "round"
|
|
270
|
+
},
|
|
271
|
+
"globe": {
|
|
272
|
+
"width": "24",
|
|
273
|
+
"height": "24",
|
|
274
|
+
"viewBox": "0 0 24 24",
|
|
275
|
+
"fill": "none",
|
|
276
|
+
"stroke": "currentColor",
|
|
277
|
+
"stroke-width": "1.7",
|
|
278
|
+
"stroke-linecap": "round",
|
|
279
|
+
"stroke-linejoin": "round"
|
|
280
|
+
},
|
|
120
281
|
"grip": {
|
|
121
282
|
"viewBox": "0 0 24 24",
|
|
122
283
|
"fill": "currentColor",
|
|
123
284
|
"stroke": "none"
|
|
124
285
|
},
|
|
286
|
+
"height": {
|
|
287
|
+
"width": "24",
|
|
288
|
+
"height": "24",
|
|
289
|
+
"viewBox": "0 0 24 24",
|
|
290
|
+
"fill": "none",
|
|
291
|
+
"stroke": "currentColor",
|
|
292
|
+
"stroke-width": "1.6",
|
|
293
|
+
"stroke-linecap": "round",
|
|
294
|
+
"stroke-linejoin": "round"
|
|
295
|
+
},
|
|
125
296
|
"image": {
|
|
126
297
|
"width": "24",
|
|
127
298
|
"height": "24",
|
|
@@ -148,6 +319,26 @@ var attrs = {
|
|
|
148
319
|
"stroke-linecap": "round",
|
|
149
320
|
"stroke-linejoin": "round"
|
|
150
321
|
},
|
|
322
|
+
"limits": {
|
|
323
|
+
"width": "24",
|
|
324
|
+
"height": "24",
|
|
325
|
+
"viewBox": "0 0 24 24",
|
|
326
|
+
"fill": "none",
|
|
327
|
+
"stroke": "currentColor",
|
|
328
|
+
"stroke-width": "1.6",
|
|
329
|
+
"stroke-linecap": "round",
|
|
330
|
+
"stroke-linejoin": "round"
|
|
331
|
+
},
|
|
332
|
+
"margin": {
|
|
333
|
+
"width": "24",
|
|
334
|
+
"height": "24",
|
|
335
|
+
"viewBox": "0 0 24 24",
|
|
336
|
+
"fill": "none",
|
|
337
|
+
"stroke": "currentColor",
|
|
338
|
+
"stroke-width": "1.6",
|
|
339
|
+
"stroke-linecap": "round",
|
|
340
|
+
"stroke-linejoin": "round"
|
|
341
|
+
},
|
|
151
342
|
"menu": {
|
|
152
343
|
"viewBox": "0 0 24 24",
|
|
153
344
|
"fill": "none",
|
|
@@ -156,6 +347,16 @@ var attrs = {
|
|
|
156
347
|
"stroke-linecap": "round",
|
|
157
348
|
"stroke-linejoin": "round"
|
|
158
349
|
},
|
|
350
|
+
"mobile": {
|
|
351
|
+
"width": "24",
|
|
352
|
+
"height": "24",
|
|
353
|
+
"viewBox": "0 0 24 24",
|
|
354
|
+
"fill": "none",
|
|
355
|
+
"stroke": "currentColor",
|
|
356
|
+
"stroke-width": "1.6",
|
|
357
|
+
"stroke-linecap": "round",
|
|
358
|
+
"stroke-linejoin": "round"
|
|
359
|
+
},
|
|
159
360
|
"named-slots": {
|
|
160
361
|
"viewBox": "0 0 24 24",
|
|
161
362
|
"fill": "none",
|
|
@@ -180,6 +381,16 @@ var attrs = {
|
|
|
180
381
|
"stroke-linecap": "round",
|
|
181
382
|
"stroke-linejoin": "round"
|
|
182
383
|
},
|
|
384
|
+
"position": {
|
|
385
|
+
"width": "24",
|
|
386
|
+
"height": "24",
|
|
387
|
+
"viewBox": "0 0 24 24",
|
|
388
|
+
"fill": "none",
|
|
389
|
+
"stroke": "currentColor",
|
|
390
|
+
"stroke-width": "1.6",
|
|
391
|
+
"stroke-linecap": "round",
|
|
392
|
+
"stroke-linejoin": "round"
|
|
393
|
+
},
|
|
183
394
|
"redo": {
|
|
184
395
|
"viewBox": "0 0 24 24",
|
|
185
396
|
"fill": "none",
|
|
@@ -188,6 +399,16 @@ var attrs = {
|
|
|
188
399
|
"stroke-linecap": "round",
|
|
189
400
|
"stroke-linejoin": "round"
|
|
190
401
|
},
|
|
402
|
+
"row": {
|
|
403
|
+
"width": "24",
|
|
404
|
+
"height": "24",
|
|
405
|
+
"viewBox": "0 0 24 24",
|
|
406
|
+
"fill": "none",
|
|
407
|
+
"stroke": "currentColor",
|
|
408
|
+
"stroke-width": "1.6",
|
|
409
|
+
"stroke-linecap": "round",
|
|
410
|
+
"stroke-linejoin": "round"
|
|
411
|
+
},
|
|
191
412
|
"search": {
|
|
192
413
|
"viewBox": "0 0 24 24",
|
|
193
414
|
"fill": "none",
|
|
@@ -196,6 +417,16 @@ var attrs = {
|
|
|
196
417
|
"stroke-linecap": "round",
|
|
197
418
|
"stroke-linejoin": "round"
|
|
198
419
|
},
|
|
420
|
+
"sides": {
|
|
421
|
+
"width": "24",
|
|
422
|
+
"height": "24",
|
|
423
|
+
"viewBox": "0 0 24 24",
|
|
424
|
+
"fill": "none",
|
|
425
|
+
"stroke": "currentColor",
|
|
426
|
+
"stroke-width": "1.6",
|
|
427
|
+
"stroke-linecap": "round",
|
|
428
|
+
"stroke-linejoin": "round"
|
|
429
|
+
},
|
|
199
430
|
"sliders": {
|
|
200
431
|
"width": "24",
|
|
201
432
|
"height": "24",
|
|
@@ -226,6 +457,26 @@ var attrs = {
|
|
|
226
457
|
"viewBox": "0 0 24 24",
|
|
227
458
|
"fill": "none"
|
|
228
459
|
},
|
|
460
|
+
"tablet": {
|
|
461
|
+
"width": "24",
|
|
462
|
+
"height": "24",
|
|
463
|
+
"viewBox": "0 0 24 24",
|
|
464
|
+
"fill": "none",
|
|
465
|
+
"stroke": "currentColor",
|
|
466
|
+
"stroke-width": "1.6",
|
|
467
|
+
"stroke-linecap": "round",
|
|
468
|
+
"stroke-linejoin": "round"
|
|
469
|
+
},
|
|
470
|
+
"text": {
|
|
471
|
+
"width": "24",
|
|
472
|
+
"height": "24",
|
|
473
|
+
"viewBox": "0 0 24 24",
|
|
474
|
+
"fill": "none",
|
|
475
|
+
"stroke": "currentColor",
|
|
476
|
+
"stroke-width": "1.6",
|
|
477
|
+
"stroke-linecap": "round",
|
|
478
|
+
"stroke-linejoin": "round"
|
|
479
|
+
},
|
|
229
480
|
"trash": {
|
|
230
481
|
"viewBox": "0 0 24 24",
|
|
231
482
|
"fill": "none",
|
|
@@ -259,6 +510,26 @@ var attrs = {
|
|
|
259
510
|
"stroke-width": "2",
|
|
260
511
|
"stroke-linecap": "round",
|
|
261
512
|
"stroke-linejoin": "round"
|
|
513
|
+
},
|
|
514
|
+
"width": {
|
|
515
|
+
"width": "24",
|
|
516
|
+
"height": "24",
|
|
517
|
+
"viewBox": "0 0 24 24",
|
|
518
|
+
"fill": "none",
|
|
519
|
+
"stroke": "currentColor",
|
|
520
|
+
"stroke-width": "1.6",
|
|
521
|
+
"stroke-linecap": "round",
|
|
522
|
+
"stroke-linejoin": "round"
|
|
523
|
+
},
|
|
524
|
+
"wrap": {
|
|
525
|
+
"width": "24",
|
|
526
|
+
"height": "24",
|
|
527
|
+
"viewBox": "0 0 24 24",
|
|
528
|
+
"fill": "none",
|
|
529
|
+
"stroke": "currentColor",
|
|
530
|
+
"stroke-width": "1.6",
|
|
531
|
+
"stroke-linecap": "round",
|
|
532
|
+
"stroke-linejoin": "round"
|
|
262
533
|
}
|
|
263
534
|
};
|
|
264
535
|
//#endregion
|
|
@@ -279,13 +550,6 @@ var VIcon_default = /* @__PURE__ */ defineComponent({
|
|
|
279
550
|
}
|
|
280
551
|
});
|
|
281
552
|
//#endregion
|
|
282
|
-
//#region \0plugin-vue:export-helper
|
|
283
|
-
var _plugin_vue_export_helper_default = (sfc, props) => {
|
|
284
|
-
const target = sfc.__vccOpts || sfc;
|
|
285
|
-
for (const [key, val] of props) target[key] = val;
|
|
286
|
-
return target;
|
|
287
|
-
};
|
|
288
|
-
//#endregion
|
|
289
553
|
//#region src/editor/ui/dialog.ts
|
|
290
554
|
var dialogKey = Symbol("mech-dialog");
|
|
291
555
|
/** Create the reactive dialog store (provided once by the editor shell). */
|
|
@@ -316,6 +580,127 @@ function useDialog() {
|
|
|
316
580
|
return store;
|
|
317
581
|
}
|
|
318
582
|
//#endregion
|
|
583
|
+
//#region src/editor/lib/image-size.ts
|
|
584
|
+
/** Largest dimension below which no LQIP is generated — icons stay as-is. */
|
|
585
|
+
var LQIP_MIN_DIMENSION = 256;
|
|
586
|
+
/** Pixel width of the generated LQIP preview. */
|
|
587
|
+
var LQIP_WIDTH = 24;
|
|
588
|
+
/**
|
|
589
|
+
* Decode an image file locally: intrinsic dimensions plus — for images of
|
|
590
|
+
* {@link LQIP_MIN_DIMENSION}+ — a tiny data-URI preview for `<Image>`'s
|
|
591
|
+
* blur-up. Runs entirely in the browser (createImageBitmap + canvas), so no
|
|
592
|
+
* server-side image library is needed. Resolves `null` when the file can't be
|
|
593
|
+
* decoded (unsupported format, SVG, jsdom) — callers fall back gracefully.
|
|
594
|
+
*/
|
|
595
|
+
async function analyzeImageFile(file) {
|
|
596
|
+
try {
|
|
597
|
+
const bitmap = await createImageBitmap(file);
|
|
598
|
+
const { width, height } = bitmap;
|
|
599
|
+
const info = {
|
|
600
|
+
width,
|
|
601
|
+
height
|
|
602
|
+
};
|
|
603
|
+
if (Math.max(width, height) >= LQIP_MIN_DIMENSION) {
|
|
604
|
+
const canvas = document.createElement("canvas");
|
|
605
|
+
canvas.width = LQIP_WIDTH;
|
|
606
|
+
canvas.height = Math.max(1, Math.round(height / width * LQIP_WIDTH));
|
|
607
|
+
const context = canvas.getContext("2d");
|
|
608
|
+
if (context) {
|
|
609
|
+
context.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
|
|
610
|
+
const uri = canvas.toDataURL("image/webp", .6);
|
|
611
|
+
if (uri.startsWith("data:image/")) info.lqip = uri;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
bitmap.close();
|
|
615
|
+
return info;
|
|
616
|
+
} catch {
|
|
617
|
+
return null;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* {@link analyzeImageFile} for an already-uploaded URL: fetch the file and
|
|
622
|
+
* decode it locally. This is how *library picks* get dimensions + LQIP — there
|
|
623
|
+
* is no `File` in hand, only the asset's src. Null on any failure.
|
|
624
|
+
*/
|
|
625
|
+
async function analyzeImageUrl(src) {
|
|
626
|
+
try {
|
|
627
|
+
const response = await fetch(src);
|
|
628
|
+
if (!response.ok) return null;
|
|
629
|
+
return await analyzeImageFile(await response.blob());
|
|
630
|
+
} catch {
|
|
631
|
+
return null;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
/** Largest dimension a free (unsized) crop derivative is downscaled to. */
|
|
635
|
+
var CROP_MAX_DIMENSION = 2560;
|
|
636
|
+
/** WebP quality for cropped derivatives — the real rendered image, not an LQIP. */
|
|
637
|
+
var CROP_QUALITY = .85;
|
|
638
|
+
/**
|
|
639
|
+
* Crop + downscale an image entirely in the browser (createImageBitmap + canvas):
|
|
640
|
+
* take the {@link NormalizedRect} region of the source at `src`, scale it to fit
|
|
641
|
+
* `target` (or capped at {@link CROP_MAX_DIMENSION} when no target), and encode a
|
|
642
|
+
* WebP blob. Never upscales. Resolves `null` when the source can't be fetched or
|
|
643
|
+
* decoded (SVG, CORS, jsdom) — the caller keeps the focal-only path. The blob is
|
|
644
|
+
* uploaded as a derived asset; `width`/`height` are its intrinsic size.
|
|
645
|
+
*/
|
|
646
|
+
async function renderCrop(src, rect, target = {}) {
|
|
647
|
+
try {
|
|
648
|
+
const response = await fetch(src);
|
|
649
|
+
if (!response.ok) return null;
|
|
650
|
+
const bitmap = await createImageBitmap(await response.blob());
|
|
651
|
+
const sx = rect.x * bitmap.width;
|
|
652
|
+
const sy = rect.y * bitmap.height;
|
|
653
|
+
const sw = rect.width * bitmap.width;
|
|
654
|
+
const sh = rect.height * bitmap.height;
|
|
655
|
+
if (sw < 1 || sh < 1) {
|
|
656
|
+
bitmap.close();
|
|
657
|
+
return null;
|
|
658
|
+
}
|
|
659
|
+
const scale = target.width && target.height ? Math.min(1, target.width / sw, target.height / sh) : Math.min(1, CROP_MAX_DIMENSION / Math.max(sw, sh));
|
|
660
|
+
const outW = Math.max(1, Math.round(sw * scale));
|
|
661
|
+
const outH = Math.max(1, Math.round(sh * scale));
|
|
662
|
+
const canvas = document.createElement("canvas");
|
|
663
|
+
canvas.width = outW;
|
|
664
|
+
canvas.height = outH;
|
|
665
|
+
const context = canvas.getContext("2d");
|
|
666
|
+
if (!context) {
|
|
667
|
+
bitmap.close();
|
|
668
|
+
return null;
|
|
669
|
+
}
|
|
670
|
+
context.drawImage(bitmap, sx, sy, sw, sh, 0, 0, outW, outH);
|
|
671
|
+
bitmap.close();
|
|
672
|
+
const blob = await canvasToBlob(canvas, "image/webp", CROP_QUALITY);
|
|
673
|
+
return blob ? {
|
|
674
|
+
blob,
|
|
675
|
+
width: outW,
|
|
676
|
+
height: outH
|
|
677
|
+
} : null;
|
|
678
|
+
} catch {
|
|
679
|
+
return null;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
/** Promisified `canvas.toBlob` (jsdom lacks it → null, caller falls back). */
|
|
683
|
+
function canvasToBlob(canvas, type, quality) {
|
|
684
|
+
if (typeof canvas.toBlob !== "function") return Promise.resolve(null);
|
|
685
|
+
return new Promise((resolve) => canvas.toBlob((blob) => resolve(blob), type, quality));
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Intrinsic pixel size of an image URL, via the browser's image loader.
|
|
689
|
+
* Resolves `null` when the image can't be loaded or reports no size — callers
|
|
690
|
+
* simply skip the dimensions then, never fail.
|
|
691
|
+
*/
|
|
692
|
+
function readImageSize(src) {
|
|
693
|
+
return new Promise((resolve) => {
|
|
694
|
+
const image = new Image();
|
|
695
|
+
image.onload = () => resolve(image.naturalWidth > 0 ? {
|
|
696
|
+
width: image.naturalWidth,
|
|
697
|
+
height: image.naturalHeight
|
|
698
|
+
} : null);
|
|
699
|
+
image.onerror = () => resolve(null);
|
|
700
|
+
image.src = src;
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
//#endregion
|
|
319
704
|
//#region src/editor/ui/VDialog.vue?vue&type=script&setup=true&lang.ts
|
|
320
705
|
var _hoisted_1$1 = { class: "mech-modal__header" };
|
|
321
706
|
var _hoisted_2$1 = { class: "mech-modal__title" };
|
|
@@ -389,7 +774,20 @@ var ImagePickerDialog_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
|
|
|
389
774
|
loaded.value = true;
|
|
390
775
|
}
|
|
391
776
|
}
|
|
392
|
-
function select(value) {
|
|
777
|
+
async function select(value) {
|
|
778
|
+
const missingPreview = !value.previewSrc || value.previewSrc === value.src;
|
|
779
|
+
if (!value.width || !value.height || missingPreview) {
|
|
780
|
+
const info = await analyzeImageUrl(value.src);
|
|
781
|
+
const size = info ?? await readImageSize(value.src);
|
|
782
|
+
value = {
|
|
783
|
+
...value,
|
|
784
|
+
...size ? {
|
|
785
|
+
width: size.width,
|
|
786
|
+
height: size.height
|
|
787
|
+
} : {},
|
|
788
|
+
...info?.lqip && missingPreview ? { previewSrc: info.lqip } : {}
|
|
789
|
+
};
|
|
790
|
+
}
|
|
393
791
|
props.onSelect(value);
|
|
394
792
|
dialog.back();
|
|
395
793
|
}
|
|
@@ -397,10 +795,16 @@ var ImagePickerDialog_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
|
|
|
397
795
|
if (!uploader || busy.value) return;
|
|
398
796
|
busy.value = true;
|
|
399
797
|
try {
|
|
400
|
-
const result = await uploader(file);
|
|
401
|
-
|
|
798
|
+
const [result, info] = await Promise.all([uploader(file), analyzeImageFile(file)]);
|
|
799
|
+
const width = result.width ?? info?.width;
|
|
800
|
+
const height = result.height ?? info?.height;
|
|
801
|
+
await select({
|
|
402
802
|
src: result.src,
|
|
403
|
-
previewSrc: result.previewSrc ?? result.src
|
|
803
|
+
previewSrc: result.previewSrc ?? info?.lqip ?? result.src,
|
|
804
|
+
...width && height ? {
|
|
805
|
+
width,
|
|
806
|
+
height
|
|
807
|
+
} : {}
|
|
404
808
|
});
|
|
405
809
|
} finally {
|
|
406
810
|
busy.value = false;
|
|
@@ -463,6 +867,6 @@ var ImagePickerDialog_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
|
|
|
463
867
|
});
|
|
464
868
|
};
|
|
465
869
|
}
|
|
466
|
-
}), [["__scopeId", "data-v-
|
|
870
|
+
}), [["__scopeId", "data-v-4ef9dd0d"]]);
|
|
467
871
|
//#endregion
|
|
468
|
-
export {
|
|
872
|
+
export { renderCrop as a, useDialog as c, _plugin_vue_export_helper_default as d, readImageSize as i, VIcon_default as l, VDialog_default as n, createDialogStore as o, analyzeImageFile as r, dialogKey as s, ImagePickerDialog_default as t, contents as u };
|